
Tobias Schwinger wrote:
Edward Diener wrote:
It would be much easier, and less confusing, when looking at compiler workarounds in Boost code if their were defines for various compilers/versions in a configuratiion header file such as:
#define BOOST_COMPILER_SOME_COMPILER_LOWER (PREPROCESSOR_TAG >= nnnn) #define BOOST_COMPILER_SOME_COMPILER_UPPER (PREPROCESSOR_TAG <= nnnn) #define BOOST_COMPILER_SOME_COMPILER (BOOST_COMPILER_SOME_COMPILER_LOWER && BOOST_COMPILER_SOME_COMPILER_UPPER)
where SOME_COMPILER might be VC71,GCC40 etc.
Then in code one could see:
#if defined(BOOST_COMPILER_VC71) etc.
rather than the less understandable
#if defined(MSC_VER == nnnn) etc.
I would just like to see more readability in the Boost code regarding compiler workarounds. I am also aware their is a workaround macro, but even that deals in compiler preprocessor tags rather than a more readable compiler version. I am aware that many workarounds have to deal with versions before or after a certain version number but even that can be made more readable by macros which tell one the actual compiler which is involved.
I realize I am just a reader of Boost code and not a Boost developer but I think this suggestion would make for a little more readable code in its own small way.
How about these?
#define BOOST_COMPILER_WITH_VERSION(compiler,version) \ (compiler == version)
#define BOOST_COMPILER_ABOVE_VERSION(compiler,version) \ (compiler > version)
#define BOOST_COMPILER_FROM_VERSION(compiler,version) \ (compiler >= version)
#define BOOST_COMPILER_BELOW_VERSION(compiler,version) \ ((compiler != 0) && (compiler < version))
#define BOOST_COMPILER_UP_TO_VERSION(compiler,vesionr) \ ((compiler != 0) && (compiler <= version))
#define BOOST_COMPILER_FROM_TO_VERSION(compiler,min_version,max_version) \ ((compiler != 0) && ((compiler >= min_version) && (compiler <= max_version)))
Example:
#if BOOST_COMPILER_BELOW_VERSION(BOOST_MSVC,1400) ... #endif
No, you have missed my entire point. I want a specific compiler version, by a name which everybody knows, ie. VC71, BCB6 etc., to be associated with the preprocessor tags which the compiler vendor uses to specify that version of the compiler, ie. MSC_VER, __BORLANDC__, in such a way that the code in Boost which provides workarounds or specific code for a given compiler, actually refers to a macro which easily identities that compiler. Your macros above just duplicate the difficulty which already exists in Boost in identifying a well-known name for a compiler/version with the preprocessor macro used in Boost to identify it.