Recent

Author Topic: WPARAM definition  (Read 494 times)

440bx

  • Hero Member
  • *****
  • Posts: 5466
WPARAM definition
« on: May 18, 2025, 06:43:54 am »
In FPC, the definition of WPARAM is "WPARAM = LONG_PTR", unfortunately, this is incorrect.  WPARAM is a UINT_PTR.

In most cases, it doesn't make a difference because the type size is the same but, it causes a problem, specifically type mismatches, when a Window proc is defined correctly and a pointer to that correctly defined proc is specified in some structure that uses FPC's WNDPROC definition.  The mismatch occurs because in the FPC definition, the WPARAM parameter is a LONG_PTR whereas the correct window proc has it as a UINT_PTR.

For instance, this occurs when specifying the Window procedure in the TWndClassEx which wants a pointer to the window proc in lpfnWndProc.

Unfortunately, it may not be easy to correct this because it may potentially affect quite a few programs but, I believe there should be awareness of the problem.

HTH.
« Last Edit: May 18, 2025, 06:53:15 am by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 17176
  • Ceterum censeo Trump esse delendam
Re: WPARAM definition
« Reply #1 on: May 18, 2025, 03:24:32 pm »
This dates back from your favorite D2 era.
There are a few people aware of it.  :-X
« Last Edit: May 18, 2025, 03:26:46 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12264
  • FPC developer.
Re: WPARAM definition
« Reply #2 on: May 18, 2025, 03:33:46 pm »
Yes, Delphi translated a lot to signed types in the early days because a proper 32-bit unsigned only appeared later (D4?). Backwards compatibility, and it doesn't hurt unless people start to define their own "correct" structures.

However, I know Delphi adjusted a few since (probably because of BCB?), but kept the one in interfaces signed IIRC. Try changing it and recompile Lazarus (bigide or bigger) to see if it creates a lot of problems.

Thaddy

  • Hero Member
  • *****
  • Posts: 17176
  • Ceterum censeo Trump esse delendam
Re: WPARAM definition
« Reply #3 on: May 18, 2025, 04:16:52 pm »
IIRC it is the diference between D4 and D5 where the compiler hardly changed and the D5 rtl was compilable with D4. I was rather taken aback at the time. Anyway, D5 and D7 were stable.
Up until and including 2009 I tested them. (Also D1, which was a very rare privilage)
« Last Edit: May 18, 2025, 04:20:50 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018