[fpc-devel]Delphi incompatibility again!

Pavel V. Ozerski pavel at insect.mail.iephb.ru
Mon Apr 2 14:40:29 CEST 2001


Hello,
Again a Delphi incompatibility is found! At least with Delphi 3. Essence: the internals of longbool, wordbool and bytebool
types in FPC aren't the same as in Delphi 3. That causes serious problems by porting Delphi code with typecastings
like word(a_wordbool_variable), e.g. by calculating of index offsets in arrays!

A sample which demonstrates differences between FPC and Delphi 3:

{$ifdef fpc}
{$mode delphi}
{$endif}
{$apptype console}
const
 x:longbool=true;
 y:wordbool=true;
 z:bytebool=true;
 w:boolean=true;
begin
 writeln(longint(x),' ',word(y),' ',byte(z),' ',byte(w));
end.

Output:
1) sample is compiled by FPC:
1 1 1 1
2) sample is compiled by Delphi 3:
-1 65535 255 1

Cause (only essence, I did not search details in compiler source):
Delphi 3 sets ALL bits in variable to binary 1 if the variable value will be true and its type is
longbool, wordbool or even bytebool (unlike boolean).
Unlike Delphi, FPC uses actually only one bit.

Sincerely, Pavel
--
Pavel V. Ozerski            | Inst. of Evolutionary Physiology & Biochemistry,
office +7 (812)552-6870(291)|           Russian Academy of Sciences,
FAX    +7 (812)552-3012     |  Thorez pr. 44, St.Petersburg, 194223, Russia
home   +7 (812)528-5576     |  E-mail:  pavel at insect.mail.iephb.ru
                            |           pavel at insect.ief.spb.su





More information about the fpc-devel mailing list