I am writing a program that is cross platform. There are a few spots where I have to specify an operating system dependent call.
#ifdef WINDOWS
..do windows only stuff
#endif
#ifdef LINUX
..do linux only stuff
#endif
Are there any preprocesser directives that get defined by the compiler so I don’t have to explicitly define them when I use the command line compiler. ie.
cl -DWINDOWS program.cpp
or
g++ -DLINUX program.cpp
I realize I could easily write a makefile or have a shell/batch script that will do this automatically. But I would prefer to use the same ones as the compiler (if they exist) by default.
I found a complete list for all g++’s on this website.
#define __HAVE_BUILTIN_SETJMP__ 1#define __unix__ 1#define unix 1#define __i386__ 1#define __SIZE_TYPE__ unsigned int#define __ELF__ 1#define __GNUC_PATCHLEVEL__ 3#define __linux 1#define __unix 1#define __linux__ 1#define __USER_LABEL_PREFIX__#define linux 1#define __STDC_HOSTED__ 1#define __EXCEPTIONS 1#define __GXX_WEAK__ 1#define __WCHAR_TYPE__ long int#define __gnu_linux__ 1#define __WINT_TYPE__ unsigned int#define __GNUC__ 3#define __cplusplus 1#define __DEPRECATED 1#define __GNUG__ 3#define __GXX_ABI_VERSION 102#define i386 1#define __GNUC_MINOR__ 2#define __STDC__ 1#define __PTRDIFF_TYPE__ int#define __tune_i386__ 1#define __REGISTER_PREFIX__#define __NO_INLINE__ 1#define _GNU_SOURCE 1#define __i386 1#define __VERSION__ "3.2.3 20030502 (Red Hat Linux 3.2.3-47.3)"And Visual C++ already has Win32 defined to use for any Widnows version.