On 01/10/2010 17:33, Mark Daems wrote:
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
if you can put it after the uses clause (so you can have a const
section, the following worked for me:
{$IFNDEF FPC}
const fpc_version=1; fpc_release=1;
{$ENDIF}
// your code below
{$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}
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
{$IF Defined(fpc_version) and ((fpc_version>word(2)) or
(fpc_version=word(2)) and (fpc_release>word(3)))}
gets rid of the warnings
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal