[Lazarus] Where to define conditionals for FPC

Bo Berglund bo.berglund at gmail.com
Fri May 8 18:03:00 CEST 2020

On Fri, 8 May 2020 17:19:30 +0200, Sven Barth via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

>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.

Well LazSerial was just an example...

I am going over the code to remove functionality that has been
outdated over the years and uses components that are hard to port.

I have created a bunch of conditionals which I can use to select or
block certain functions in the code. I have also at the same time
added the conditionals for FPC to switch between for example LazSerial
and the corresponding serial component in Windows (there are actually
two that can be selected between using another conditional in

All of this works OK in Delphi 2007 when I use the GUI to set the
conditional variables.

But what is worrying me is that the Lazarus Delphi Converter will not
find these conditionals and then convert stuff that are to be Delphi
As far as I have understood the converter does not read the dproj file
where Delphi stores these settings.
But I might be overly anxious? Maybe Lazarus Delphi Converter can read
the dproj file and find the settings?

I made a test conversion a number of weeks ago and it failed because
of a lot of dependencies on components with no FCP counterpart etc...
Then I had to backtrack a lot to get the project in working order
again and decided to try to make the code FPC aware via the
conditionals and still keep the way it works now.

Maybe I can just enclose the ifdef's in an outer layer ifdef DELPHI?
Does the converter skip such sections during the conversion?


Then Sentinel will only ever be used if built by Delphi and only if
SUPERPRO is set, right?

Bo Berglund
Developer in Sweden

More information about the lazarus mailing list