8
votes

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}
2

2 Answers

13
votes

Use FPC             

{$IFDEF FPC}
1
votes

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.