<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to VersionNormalization</title><link>https://sourceforge.net/p/predef/wiki/VersionNormalization/</link><description>Recent changes to VersionNormalization</description><atom:link href="https://sourceforge.net/p/predef/wiki/VersionNormalization/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 01 Aug 2012 09:52:40 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/predef/wiki/VersionNormalization/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage VersionNormalization modified by Bjorn Reese</title><link>https://sourceforge.net/p/predef/wiki/VersionNormalization/</link><description>## Version Normalization ##

The pre-defined macros specify version numbering in different ways, which makes it annoying to check for specific compiler versions. In this case you can normalize the version number of the different compilers. For example:

    :::c
    /* Version is 0xVVRRPPPP */
    #define PREDEF_VERSION(v,r,p) (((v) &lt;&lt; 24) + ((r) &lt;&lt; 16) + (p))
 
    /* Normalize GCC version */
    #if defined(__GNUC__)
    # if defined(__GNUC_PATCHLEVEL__)
    #  define PREDEF_COMPILER_GNUC PREDEF_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
    # else
    #  define PREDEF_COMPILER_GNUC PREDEF_VERSION(__GNUC__, __GNUC_MINOR__, 0)
    # endif
    #endif
 
    /* Normalize Visual Studio version */
    #if defined(_MSC_FULL_VER)
    # define PREDEF_COMPILER_MSC PREDEF_VERSION(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, _MSC_FULL_VER % 10000)
    #else
    # if defined(_MSC_VER)
    #  define PREDEF_COMPILER_MSC CDETECT_MKVER(_MSC_VER / 100, _MSC_VER % 100, 0)
    # endif
    #endif

This can then be used like this:

    :::c
    #if defined(PREDEF_COMPILER_GNUC) &amp;&amp; (PREDEF_COMPILER_GNUC &gt;= PREDEF_VERSION(4, 6, 0))
    /* GNU C/C++ compiler version 4.6.0 or newer */
    #endif
</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Bjorn Reese</dc:creator><pubDate>Wed, 01 Aug 2012 09:52:40 -0000</pubDate><guid>https://sourceforge.net89a555b82ee83c49a83f395ab90810afb0852b27</guid></item></channel></rss>