Member Avatar for jmichae3

I am going to assume that gcc is the compiler people are using on their *NIX.
so for that, I know that

#if defined(__GNUC__)

will work.
SO...
for Centos, Solaris, HPUX, AIX, Linux, BSD, FreeBSD, OpenSUSE, Fedora, redhat, what #if defined()'s do I use to detect these OS's?

Member Avatar for jmichae3

CHANGE to request:
I am going to assume that gcc is the compiler people are using on their *NIX.
so for that, I know that

#if defined(__GNUC__)

will work.
SO... for
Centos,
Solaris,
HPUX,
AIX,
Linux, (actually anything grouped under "linux" (now I understand is #if defined(linux))
BSD,
FreeBSD,
OpenSUSE,
Fedora,
redhat,
what #if defined()'s do I use to detect these OS's?

I also need to know what they use for
strnicmp,
stricmp,
strcmp,
strdup,
strlwr.

I do not have these OS's. but as many as I can get info for, this would be great. I am making a set of cross-platform translation header, and ways to disable globbing on the compilers on those platforms. I have globbing disable info for mingw and DJGPP and mingw-w64, but not linux or other OS's gcc. this info would also be appreciated.

You may look at how other cross-platform software does this. Consider boost - which is fairly compatible on multiple platforms.
In boost you will find a select_platform_config.hpp which has code similar to

#if defined(linux) || defined(__linux) || defined(__linux__)
// linux:
#  define BOOST_PLATFORM_CONFIG "boost/config/platform/linux.hpp"

#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
// BSD:
#  define BOOST_PLATFORM_CONFIG "boost/config/platform/bsd.hpp"

#elif defined(sun) || defined(__sun)
// solaris:
#  define BOOST_PLATFORM_CONFIG "boost/config/platform/solaris.hpp"

//...

and so on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.