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

Marco van de Voort marcov at stack.nl
Sun Sep 18 14:19:20 CEST 2011


In our previous episode, Fl?vio Etrusco said:
> > http://delphi.wikia.com/wiki/FreePascal_detection_and_versioning
> >
> > a typical usage:
> >
> > {$if FPC_FULLVERSION> 20204}
> > ? // means greater than 2.2.4 here
> > ?{$ifndef}
> >
> 
> Not wanting to hijack the thread but, why isn't there a way to print
> macro values? (There isn't, is it?)

No. http://bugs.freepascal.org/view.php?id=12935

I still think this is a good thing, mostly because this is a way to get
versions etc embedded in the program into the binary without going through
an includefile processor.

so

 fpc  -dfreebsdversion:=`uname -r`

and then
  {$i %freebsdversion%}

According to Jonas it can also be done via the environment, and for me that
was enough back then (which is why the report is closed). But in retrospect
that is fine for commandline, but harder for IDE usage. (which often allows
to set additional cmdline options, but not specify the environment,
specially not on all targets)



More information about the fpc-pascal mailing list