Click to See Complete Forum and Search --> : Q on porting C/C++ code(Precompiler def)


tecknophreak
10-15-2003, 08:56 AM
I've got a program for linux which has a few headers which need to be changed so that it'll compile on VC++. Is there a precompiler def to check to see if the OS is Linux or Windows? Looking to do something like:

#ifdef __LINUX__

#include <sys/types.h>
#include <sys/socket.h>

#else // WINDOWS

#include <winsock.h>

#endif

First time taking code to a windows box which actually needs to be changed to work on windows. :(

Stuka
10-15-2003, 10:15 AM
There is - _WIN32 is defined for 32 bit windows systems.

tecknophreak
10-15-2003, 10:33 AM
Excellent, thank you.

bwkaz
10-15-2003, 06:46 PM
And either _UNIX_, __UNIX__, __unix__, or some variant of that shoud be defined on most Unix-like compilers (gcc does define __unix__).