Click to See Complete Forum and Search --> : #defines


Kohinoor24
August 1st, 2002, 05:14 AM
Helo,
Iam trying to port my application developed under windows to Linux.

I want to put some codes between #define's.
For Eg:-

Iam giving "WIN32" for windows.What is the equivalent for Linux

Thanks in advance

stober
August 1st, 2002, 05:36 AM
_WIN32 is Microsoft-specific symbol that is defined by the VC6 (and earlier) IDE and used in many of the VC6 header files. Its not a standard C/C++ definition. In Linux you can define anything you want. What I normally do is something like this:

In a header file that is included in all other *.cpp files:
#define _LINUX

Then in the *.cpp file:

#if defined(_WIN32)
// MS Windows stuff
#else if defined(_LINUX)
// linux stuff
#else
// some other operating system
#endif

Zeeshan
August 1st, 2002, 05:37 AM
I wrote this when developing code for both Linux and Windows


#ifdef __linux__

// Linux Code

#endif


And if __linux__ is not define on any plateform then define it myself.

Hope it helps.