Better yet:

#ifdef unix

// UNIX/Linux/*BSD.

#endif

#ifdef _WIN32

// Window stuff

#endif

Both symbols are auto defined by the compiler.

Gilboa

On Thu, 2003-07-03 at 18:48, Nadav Har'El wrote:
> On Thu, Jul 03, 2003, Voguemaster wrote about "Cross platform code":
> > The problem is very basic: Linux and Win32 have different include files
> > for some things and placing #include directives inside #ifdef doesn't
> > do the trick (it nullifies the #ifdef possibly ?????).
> 
> You probably made some mistake - #include doesn't nullify #ifdef or
> anything of that sort :) (you might want to refer to any C book, or the
> "cpp" info-page, for more information)
> 
> You can have something like
> 
> #ifdef LINUX_SYSTEM
> #include <this/is/available/only/on/linux.h>
> #else
> #include <a/windows/include/file.h>
> #endif
> 
> And when you compile on the Linux system, add a "-DLINUX_SYSTEM" in the
> command line. Alternatively, you can use predefined macros that are
> automatically defined on one system and not on the other. For example,
> last time I checked, the C preprocessor defines "linux" on linux systems.
> So you can replace the above example with
> 
> #ifdef linux
> #include <this/is/available/only/on/linux.h>
> #else
> #include <a/windows/include/file.h>
> #endif
> 
> The macro __linux__ is also defined in Linux, I believe. A similar macro
> (whose name I don't remember) is defined by default on Microsoft's C compiler
> on Windows.



=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to