On Mon, Jan 08, 2001 at 11:05:54PM -0800, Aaron Brashears wrote: > I'm doing some code which is intended to work on linux and sunos. I > was poking through the header files in /usr/include on my debian box > and found a line in g++-3/stl_config.h which specified: > > #if defined(__linux__) > > after a quick test, I found out this is true on linux, and not true on > solaris when using gcc. However, grep -r '__linux__' * doesn't reveal > the location where it is in fact #defined.
This is defined in the gcc specs file, see /usr/lib/gcc-lib/i386-linux/${version}/specs > Anyone have a clue what's going on? While on the topic, is there a > magic preprocessor definition that lets me know if I'm on > sunos/solaris? Just as a side note, think twice (or even thrice) before using that symbols. Is the code really linux specific? For example, a Linux kernel feature certainly is, but many other things aren't. Often it is more appropriate to check for specific POSIX features, or the existance of the GNU C library, or something else entirely. autoconf can help here, as well as "liberty" (libiberty :) Of course, this depends on the thing you want to implement, but choosing the right check makes the software more portable. To see a full list of compiler defined symbols, use gcc -dM -E - < /dev/null Thanks, Marcus