[fpc-pascal] How to do conditional compilation with macros

Reinier Olislagers reinierolislagers at gmail.com
Sun Sep 18 13:29:22 CEST 2011


Trying to test for a certain minimum version of FPC.

Have got FPC version 2.7.1 [2011/09/17] for i386 on Windows.

What am I doing wrong?

program conditional;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes;

begin
  //How should I use FPCVULLVERSION in conditional compilation?
  {$IF $FPCFULLVERSION > 20200}
  writeln('Version newer than 2.2');
  //Error: Compile time expression:
  //Wanted BOOLEAN but got INTEGER at IF or ELSEIF
  {$ENDIF}


  //so maybe the IF wants a precooked boolean result
  //let's try some brackets
  //Tried to apply Programmer's Guide 2.4 on Compile time expressions:
  {$MACRO+}
  {$IF (FPCFULLVERSION > 20200)}
  //Error: Compile time expression Wanted STRING but got INTEGER at
  //"FPCFULLVERSION > 20200"
    writeln('Version newer than 2.2 another try');
  {$ENDIF}

  //adding a $:
  {$IF ($FPCFULLVERSION > 20200)}
  //Error: Syntax error while parsing a conditional compiling expression
    writeln('Version newer than 2.2 yet another');
  {$ENDIF}
end.



More information about the fpc-pascal mailing list