kludg
kludg

Reputation: 27493

Predefined symbol to select between Lazarus and Delphi

I am looking for a predefined symbol to write a code like that:

{$IFDEF LAZARUS}
// code compiles by fpc/lazarus
{$ELSE}
// code compiles by delphi
{$ENDIF}

Upvotes: 8

Views: 999

Answers (2)

Marco van de Voort
Marco van de Voort

Reputation: 26401

For GUI applications afaik the "LCL" symbol is defined inside Lazarus projects. In this case it probably won't matter.

In general, for bigger codebases, I would avoid having too much ifdef FPC/LCL and ifdef in your sourcecode though. It makes adding an exception or other version harder.

Use a system like JCL and Zeos(7) are using, where you give most differences an own name (like "USE_FPCUNIT" or "USE_DUNIT") and link these to versions in a central includefile.

For a short treatise on the subject see http://www.stack.nl/~marcov/porting.pdf (chapter 2)

P.s. I would consider Pocketstudio, TP,GPC,VP and WDSybil (and whatever I forgot) dead for most practical purposes and the bytecode variants Canterbury Pascal/Component Pascal/Oxygene/Prism/Delphi.NET incompatible (most are more Oberon than Pascal anyway). That pretty much leaves Delphi, Kylix and FPC to worry about.

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 613582

Use FPC             

{$IFDEF FPC}

Upvotes: 14

Related Questions