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.

-- 
Nadav Har'El                        |      Thursday, Jul 3 2003, 4 Tammuz 5763
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |Guarantee: this email is 100% free of
http://nadav.harel.org.il           |magnetic monopoles, or your money back!

=================================================================
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