[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+}

  {$IFDEF UNIX}{$IFDEF UseCThreads}

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

  //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:
  {$IF (FPCFULLVERSION > 20200)}
  //Error: Compile time expression Wanted STRING but got INTEGER at
  //"FPCFULLVERSION > 20200"
    writeln('Version newer than 2.2 another try');

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

More information about the fpc-pascal mailing list