I should add that you can always use your own macro (defined inside your
makes files) in-case you don't want to count on the "compiler" doing the
work for you.

E.g.
ifdef _WINNT_

#include <windows.h>

#endif

#ifdef _LINUX_

#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <sys/socket.h>

#endif

#ifdef _FREEBSD_

// Same as Linux...
..

#endif

#ifdef _HPUX_

..etc


On Thu, 2003-07-03 at 21:08, Oleg Goldshmidt wrote:
> Gilboa Davara <[EMAIL PROTECTED]> writes:
> 
> > Better yet:
> > 
> > #ifdef unix
> > 
> > // UNIX/Linux/*BSD.
> > 
> > #endif
> > 
> > #ifdef _WIN32
> > 
> > // Window stuff
> > 
> > #endif
> > 
> > Both symbols are auto defined by the compiler.
> 
> What is "the compiler"? How can you be sure that 6 months from now
> someone in New Zealand will be using "the compiler"?
> 
> There is nothing I know of that will guarantee existence of "unix" or
> "_WIN32". Even worse, what about the cases where Solaris, AIX, HPUX,
> Linux, DG/UX, and assorted BSDs all work differently, what good is
> "unix" then? If a compiler defines something like that, it is most
> likely for its own internal use, and to comply with the system
> facilities, *not* to be exported into client code.
> 
> To the OP:
> 
> Create your own compilation environment, call your CPP macros whatever
> you want, in your Makefile or configuration files define the proper
> flags depending on the output of things like uname -s etc. In short,
> do whatever is needed but do not rely on things that *a* compiler
> defines automatically.
> 
> Finally, if you suspect that something or somebody is #undefing or
> #defining your macros without you knowing it, try to make the compiler
> #as verbose as possible - maybe there will be a clue there. Often you
> #will see what it silently #defines or #undefs on the command line then. 



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