Definitions to include in a C++ program so that it can be compiled and run under both unix and windows _______________________________________________________________ #ifdef _WIN32 #include #pragma warning (disable:4267) #pragma warning (disable:4996) #pragma warning (disable:4018) int strcasecmp(const char * s1, const char * s2) { return _stricmp(s1, s2); } #if _MSC_VER >= 1400 // this detects visual studio 2005 or later // nothing else to do in this case. // if you need more detailed detection: // _MSC_VER < 1400 && _MSC_VER >= 1310 // is for .NET 2003 // _MSC_VER < 1310 && _MSC_VER >= 1300 // is for .NET 2002 // _MSC_VER < 1300 && _MSC_VER >= 1200 // is for version 6 #else int close(int fd) { return _close(fd); } int open(const char * filename, int flags) { return _open(filename, flags); } int open(const char * filename, int flags, int protection) { return _open(filename, flags, protection); } int read(int fd, void * address, int nbytes) { return _read(fd, address, nbytes); } int write(int fd, void * address, int nbytes) { return _write(fd, address, nbytes); } int lseek(int fd, int offset, int from) { return _lseek(fd, offset, from); } const int O_RDONLY = _O_RDONLY; const int O_WRONLY = _O_WRONLY; const int O_CREAT = _O_CREAT; const int O_TRUNC = _O_TRUNC; const int O_RDWR = _O_RDWR; const int O_BINARY = _O_BINARY; const int S_IWRITE = _S_IWRITE; #endif #endif #ifdef unix #include #include const int S_IWRITE = 0600; #endif