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}
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}
Use FPC
{$IFDEF FPC}
uses
clause. DUnit implementation is specific to IDE. –
Womenfolk DCC
conditional for itself. Prior to that, there was no defining conditional to identify the Delphi compiler, except indirectly via the version-specific VERxxx
conditionals. –
Chandelle 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.
© 2022 - 2024 — McMap. All rights reserved.
FPC
is defined by the compiler rather than the IDE. So it will be correct for all IDEs that use FPC as their compiler. – Cupellation