[Lazarus] Where to define conditionals for FPC

Sven Barth pascaldragon at googlemail.com
Fri May 8 17:19:30 CEST 2020


Bo Berglund via lazarus <lazarus at lists.lazarus-ide.org> schrieb am Fr., 8.
Mai 2020, 16:54:

> 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:
> >>
> >> {$IFDEF USE_LAZSERIAL}
> >> //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?


Such an include file would need to be included in all units where a define
might be needed.

Alternatively if you always use LazSerial for FPC/Lazarus you could simply
check with "$ifdef FPC" instead.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200508/b16565d3/attachment-0003.html>


More information about the lazarus mailing list