What resources exist to aid in writing C/C++ code that works across multiple platforms and compilers? For example, I regularly find myself asking questions like:
- Which preprocessor macros are automatically defined in various compilers and environments? (e.g.
__GCC__
,WIN32
,__WIN32__
,__CYGWIN__
) - Which versions of compilers and standard libraries support relatively new "standard" functions (e.g. the C99 long double trigonometric functions sinl(), cosl(), ...)
- What functions are available on different platforms for performing typical tasks, when no single portable function seems to exist? (e.g. getting the current time with sub-second precision)
I often write code that should compile under Linux/gcc, cygwin, mingw32, and Visual Studio, and I frequently have to compare notes from multiple sources (Linux man pages, MSDN, compiler docs) to get the information I need. This must be a problem that developers run into all the time -- are there any resources that compile this information into an easily digestible reference?
(For this question I'm not particularly interested in cross-platform libraries like wxWidgets or boost. I'm more interested in resources or techniques that would help somebody write their own cross-platform library or program.)
EDIT: This is an example of the type of page I'm looking for: http://predef.sourceforge.net/precomp.html. A nice survey of various compilers/environments and the preprocessor macros that can be used to identify them. It would be great to find a similar resource that compared nearly-equivalent functions across platforms (like gmtime_r() or ftime() in Linux vs _gmtime_s() or _ftime() in Windows) when no common function exists.