[Lazarus] Where to define conditionals for FPC

Bo Berglund bo.berglund at gmail.com
Fri May 8 16:54:09 CEST 2020

On Fri, 8 May 2020 16:34:49 +0200, Gabor Boros via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>2020. 05. 08. 14:07 keltezéssel, Bo Berglund via lazarus írta:
>> I know that you can define "custom options" in Lazarus
>> Project/Options/CompilerOptions/CustomOptions/Defines
>> These can then be used in constructs like this example:
>> //Code pertaining to LazSerial
>> {$ELSE}
>> //Code pertaining to AsyncPro
>> {$ENDIF}
>> But if I do not want to use Lazarus, how do I set the conditionals I
>> want to use?
>Compile with "fpc ... -dUSE_LAZSERIAL".

I am trying to find a way to mmake the code build both in Delphi 2007
and Lazarus and since I have used conditionals to adapt the code to
different components and environments I need to handle these in a
consistent manner.
I know that I can use the Delphi and Lazarus GUI to set these
conditional variables, but in the end I need the Delphi code (I have
still not reached FPC/Lazarus for the complete project) to be accepted
by the Lazarus Delphi Conversion function and then everything I think
is read from the project sources.
In this case since Delphi 2007 stores the settings in the dproj file
and since the Converter does not read that file I am trying to find a
way to set the conditionals directly in the code...

Maybe in an include file, but where should that be included?

The dpr file only contains this after the uses file list:

  {$i conditionals.inc}  //<== Can it be here? Will it be global then?
  if not Application.DelayInitialize or Application.Installing then
  Application.CreateForm(TRemoteServer, RemoteServer);

Bo Berglund
Developer in Sweden

More information about the lazarus mailing list