| abstract
| - Free Pascal defines a lot of conditionals, both for platform as for target support. The most important one is the FPC conditional {$ifdef FPC} // put your FPC code here {$else} // assume Delphi or TP here. {$endif} Besides this, there is the matter of target (architecture and OS) support:
* a conditional per architecture (CPU family) are {$ifdef i386} // 32-bit PC code here. {$endif} {$ifdef cpux86_64} // aka AMD64. // 64-bit PC code here. {$endif} {$ifdef powerpc} // 32-bit powerpc specific code here {$endif} {$ifdef powerpc64} // 64-bit powerpc specific code here {$endif} {$ifdef m68k} // m68k, Motorola 68010+ is not supported in 2.0+ at the moment, but might be resurrected. {$endif} {$ifdef Sparc} // 32-bit Sparc support {$endif} {$ifdef Sparc64} // 64-bit Sparc support is partially done, but not releaseworthy yet. {$endif} {$ifdef Arm} // 32-bit ARM support. {$endif} // Comment from dkropf // {$ifdef i386} DOES NOT WORK! use {$ifdef cpui386}
* General conditions for wordsizes and endianness TYPE {$ifdef CPU32} SizeofPointe=32; // 32-bit = 32 {$endif} {$ifdef CPU64} SizeofPointe=64; // 64-bit = 64 {$endif} {$ifdef ENDIAN_BIG} I:=a and 255 + (b and 255) shl 16; {$endif} {$ifdef ENDIAN_LITTLE} I:=b and 255 + (a and 255) shl 16; {$endif}
* test for families of OSes. {$ifdef MSWindows} // ce + win32 + win64, delphi compat {$endif] {$ifdef Windows} // ce + win32 + win64, more logical. {$endif] {$ifdef Unix} // all Unix like OSes. Linux/*BSD/OS X and Solaris. BeOS too if it ever released again. {$endif} {$ifdef BSD} // Free/Net/OpenBSD and Mac OS X {$endif}
* Specific OSes {$ifdef win32} // 95/98/ME and 32-bit NT/2k/XP/Vista {$endif} {$ifdef win64} // 64-bit/XP/Vista {$endif} {$ifdef wince} // Windows CE family including PocketPC 2003 and Windows Mobile 5 {$endif} {$ifdef Linux} // linux} {$endif} {$ifdef FreeBSD} // FreeBSD {$endif} {$ifdef Darwin} // Darwin is the base OS name of Mac OS X, like NT is the name of the Win2k/XP/Vista kernel. Mac OS X = Darwin + GUI. {$endif} {$ifdef SunOS} // similarly with Solaris. Ifdef solaris also works though. {$endif} // additionally OS2 , netware, netwlibc (Linux based Novell), BeOS, AmigaOS.
* versions (see also FPC versions) {$ifdef ver2} // all versions 2.x {$endif} {$ifdef ver2_2} // all versions 2.2 {$endif} //etc. // or (delphi/FPC2+ style): {$if (fpc_version=2) and (fpc_release>0) or ((fpc_release=0) and (fpc_patch>3))} {$info At least this is version 2.0.4} {$else} {$fatal Problem with version check} {$endif}
* dialects {$ifdef fpc} // only warn when {$ifndef fpc_delphi} // fpc is not in delphi mode {$info please compile this unit with -Sd to enable delphi mode.} {$endof} {$endif}
* Since FPC 2.2.4, a directive FPC_FULLVERSION supports numeric comparison like this {$if FPC_FULlVERSION> 20204} // means greater than 2.2.4 here {$ifndef}
|