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

Flávio Etrusco flavio.etrusco at gmail.com
Sun Sep 18 14:39:05 CEST 2011


On Sun, Sep 18, 2011 at 9:19 AM, Marco van de Voort <marcov at stack.nl> wrote:
> 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)
> _______________________________________________


Thanks for the information and tips. I hadn't thought about using
environment variables, maybe I'll add it to Lazarus :)

Best regards,
Flávio



More information about the fpc-pascal mailing list