Hello everyone,
I've been reading a few articles about writing compatible code (cross platform, cross compiler) and I'm astonished about some of the things I read
here[
^].
I know compilers don't always implement all features, but pre-defined macros are how we can tell what we can and cannot do (in a way). For my surprise, compilers don't always correctly define these macros.
"Please notice that not all compliant compilers provides the correct pre-defined macros. For example, Microsoft Visual C++ does not define __STDC__, or Sun Workshop 4.2 supports C94 without setting __STDC_VERSION__ to the proper value. Extra checks for such compilers must be added."
"For example, IBM xlC supports Unix without setting any of the __unix__ macros."
I was trying to write a few macros that would abstract anyone who uses it from these differences. Just for the sake of it. I mean, I know how to correct most of these issues, but it's the heck of a job for a one man show... It's just endless!
It's not like I need every single issue resolved, but hey, portable code is portable, right?
So the question is: is there any project out there that already does this? SourceForge lists some alternatives, but they all seem to be tools (BuildTool, CMake, SCons, etc) and that's not quite what I'm looking for.
I think this is where open source really kicks in. Lots of people all adding definitions from their OSs, compilers, hardware, etc. If there is none, do you think it would be interesting to create a project like that?
An example. I defined this:
#if defined(unix) || defined(__unix__) || defined(__unix)
# define _USING_UNIX 1
#else
# define _USING_UNIX 0
#endif
#ifdef _WIN32
# define _USING_WINDOWS 1
#else
# define _USING_WINDOWS 0
#endif
Which seems correct, but then I read that observation about IBM xlC.