[Lazarus] Compile conditionals from Delphi do not work in Laz 1.6...

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Jul 22 00:12:17 CEST 2016


On Thu, 21 Jul 2016 23:14:23 +0200
Bo Berglund <bo.berglund at gmail.com> wrote:

> I have some shared code which has conditionals built in to check the
> Delphi version. When I use these functions in Lazarus 1.6/Fpc 3.0 on
> Windows7 I get a compile error as follows:
> 
> FormClient.pas(152,7) Error: Incompatible types: got "AnsiString"
> expected "Int64"
> FormClient.pas(152,7) Error: Compile time expression: Wanted Boolean
> but got <erroneous type> at IF or ELSEIF
> 
> The offending code looks like this:
> 
>   {$IF CompilerVersion >= 20} {Delphi 2009 = 20..}
> 	  with TMemIniFile.Create(IFile, TEncoding.UTF8) do
>   {$ELSE}
> 	  with TMemIniFile.Create(IFile) do
>   {$IFEND}
> 
> What should i do to make this error go away?

For example:

  {$IF defined(FPC)}
    TMemIniFile.Create(IFile);
  {$ElseIf CompilerVersion >= 20} {Delphi 2009 = 20..}
    TMemIniFile.Create(IFile, TEncoding.UTF8);
  {$ELSE}
    TMemIniFile.Create(IFile);
  {$IFEND}

 
> I do not understand from where it gets the error message about int64
> and AnsdiString...

CompilerVersion is only defined by the Delphi compiler.
An undefined macro is by default an empty string.
FPC uses FPC_FullVersion.

Mattias


More information about the Lazarus mailing list