[fpc-pascal] Fwd: Delphi incompatible conditionals?

Mark Daems mdaems at advalvas.be
Fri Oct 1 18:33:48 CEST 2010


Hi,

I'm trying to add following conditional code to the top of a unit that
should compile in fpc and in delphi:

{$IFDEF FPC}
 {$IFNDEF ver1}
   {$IF (fpc_version>2) or (fpc_version=2) and (fpc_release>3)}
     {$info FPC version >= 2.4.0 : Should work}
   {$ELSE}
     {$warning FPC versions below 2.4 are not supported. However :
give it a try, you never know.}
   {$IFEND}
 {$ELSE}
   {$fatal FPC version 1 isn't supported at all}
 {$ENDIF}
{$ENDIF}

This seems to work well in fpc, however the delphi (7 and 2009)
compiler complains on the {$IF ...} line.
     [DCC Error] Zeos.inc(49): E2026 Constant expression expected

Replacing the {$IF ...} line by
   {$IF Defined(fpc_version) and ((fpc_version>2) or (fpc_version=2)
and (fpc_release>3))}
seems to solve the previous problem, however then the compiler outputs
this warning 4 times for every occurence of this code:
     [DCC Warning] Zeos.inc(49): W1023 Comparing signed and unsigned
types - widened both operands
Because I want to use this code in an include file for every unit in
the project this becomes very messy.

And it's a weird behaviour, because it's all within an {$IFDEF FPC}
construct. Why does delphi even try to interprete it?

Somebody knows how to avoid the problem?

Mark



More information about the fpc-pascal mailing list