[fpc-devel] BOOL

Tomas Hajny XHajT03 at hajny.biz
Mon Dec 15 08:48:45 CET 2014


On Mon, December 15, 2014 07:58, Adriaan van Os wrote:
> Michael Van Canneyt wrote:
>>> Well, true is -1 and false 0 :) I wonder if we should forbid it in fpc
>>> mode ...
>>
>> We should. IMHO ByteBool is unsigned so >=0...
>
> I suggest to change the internal value of TRUE to 1 for all boolean types,
> except in mode delphi.
> Then "for b:= false to true" works as one would except.

Ord (true) = 1 even now (in FPC as well as in other Pascal compilers).
However, ByteBool type is a special type provided for compatibility with
Delphi (which introduced it for easier interfacing with certain MS Windows
API functions if I remember correctly) and that type requires a different
convention, so the value is transformed during the implicit conversion.
Changing the definition of type ByteBool for non-Delphi modes wouldn't
make much sense in my view. From my point of view, the primary solution
for you would be simply to stick to standard Pascal type boolean where it
works as expected. A hint about possibly unexpected behaviour of ByteBool
in for..do loops would be probably useful.

Tomas






More information about the fpc-devel mailing list