[fpc-pascal] Boolean types

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Fri Jan 3 23:53:56 CET 2014


>> b5500centralcontrol.pas(119,18) Error: Incompatible types: got
>> "ShortInt" expected "ByteBool"
 >>
 >> b5500centralcontrol.pas(119,18) Error: Incompatible types: got
 >> "ShortInt" expected "ByteBool"
 >
 > You need to cast nevertheless. It's just that they can be used in
 > place of e.g. BOOL parameters for WinAPI functions whereby the
 > argument value is passed like the underlying non-Boolean datatype.

Thanks Sven, noted and understood. In practice I've changed them all to 
qwords since this is the native size of the system being emulated, which 
leads to another question. If I have a field and property like

fPB1L: qword;
..
property PB1L: qword read: fPB1L write SetPB1L;

procedure ...SetPB1L(p: qword);
begin
   Assert((p = 0) or (p = 1));
   fPB1L := p
end;

is there an unobtrusive way of changing the property to effectively be

property PB1L: qword read fPB1L write fPB1L;

when assertions aren't being generated? The obvious way would be to use 
lots of  $IFOPT C+  but is there anything more concise and maintainable? 
Can methods be inlined, and could the compiler successfully optimise-out 
a method which was a simple assignment?

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]



More information about the fpc-pascal mailing list