PDA

View Full Version : {$IFDEF Win32}, {$IFDEF CLR}, and what for multiplatform?



cronodragon
25-10-2007, 03:10 PM
I want to port some of my classes to FPC/Lazarus, what conditional symbol can I use to detect other platforms different of Win32 and .NET? I would prefer not to use an {$ELSE} if possible. :?

Regards!
-Marco

technomage
25-10-2007, 03:12 PM
You can use.

{$IFDEF FPC} // free pascal compiler
{$ENDIF}

{$IFDEF LINUX} //linux
{$ENDIF}

{$IFDEF DARWIN} //macosx
{$ENDIF}

Hope that helps :)

cronodragon
25-10-2007, 03:23 PM
Hey thanks! :D

Is there a list of all of those defines?

Ñuño Martínez
25-10-2007, 08:43 PM
You can read the complete list of predefined symbols in the G appendix of the FPC's programmers manual.

Link (http://www.freepascal.org/docs.var)

marcov
28-10-2007, 02:15 PM
{$IFDEF LINUX} //linux
{$ENDIF}



Note that in general you want to use {$ifdef unix} for all Unix like platforms (FreeBSD, Mac OS X, Solaris , Linux).

Reserve linux for the real (relatively rare) linuxisms.

Also try to use system/sysutils variables as much as possible (e.g. dirseparator)