Free Pascal => FPC development => Topic started by: 440bx on April 04, 2019, 03:31:02 pm
Title: Mismatch in header notification definitions causes not-applicable warnings
Post by: 440bx on April 04, 2019, 03:31:02 pm
Hello,
The Header control notifications are defined as being negative constants but, the NMHDR.code they are compared against is defined as a longword.
This causes warnings from FPC. Specifically:
Warning: range check error while evaluating constants (-306 must be between 0 and 4294967295)
This occurs for all the notification codes used by the header control.
Title: Re: Mismatch in header notification definitions causes not-applicable warnings
Post by: PascalDragon on April 05, 2019, 09:14:37 am
Would you mind providing a bit more context, please? Cause right now it isn't really clear what exactly you're talking about.
Title: Re: Mismatch in header notification definitions causes not-applicable warnings
Post by: Thaddy on April 05, 2019, 09:55:52 am
NMHDR record member constants itself are declared as signed integers (probably legacy) but the winapi NMHDR expects longword members. Hence the compiler barks. (/win/wininc/struct.inc is correct, messages.inc isn't)
To suppress, cast to longword on use as a work-around. Solution is possibly to redeclare
HDM_TESTDUMMY = longword(-321);// instead of HDM_TESTDUMMY = -(321)
var i:longint;
j:longword;
begin
i:=HDM_TESTDUMMY;// testlongword.pas(6,8) Warning: Range check error while evaluating constants (4294966975 must be between -2147483648 and 2147483647)
j:=HDM_TESTDUMMY;// OK.
writeln(i,'|',j);
end.
Is that enough context? [edit] reported in Mantis as #0035324
p.s. the example actually reverses the issue to make it clear.
Title: Re: Mismatch in header notification definitions causes not-applicable warnings
Post by: ASerge on April 05, 2019, 08:13:28 pm
For clarification. SDK defines such const as unsigned (commctrl.h):