[cfe-dev] Libcxx marco using question

Howard Hinnant hhinnant at apple.com
Thu Sep 9 10:21:28 PDT 2010


On Sep 9, 2010, at 12:55 PM, Bjorn Reese wrote:

> On 2010-09-09 03:34, 罗勇刚(Yonggang Luo)  wrote:
> 
>> So the marco should be
>> #if defined(__clang__) || (__GNUC__ == 4&&  __GNUC_MINOR__>= 3) ||
>> (__GNUC__>=5)
> 
> Or...
> 
> #if defined(__GNUC__)
> # if defined(__GNUC_PATCHLEVEL__)
> #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
>                             + __GNUC_MINOR__ * 100 \
>                             + __GNUC_PATCHLEVEL__)
> # else
> #  define __GNUC_VERSION__ (__GNUC__ * 10000 \
>                             + __GNUC_MINOR__ * 100)
> # endif
> #endif
> 
> which can then be used as follows:
> 
> #if defined(__clang__) || (__GNUC_VERSION__ >= 40300)

<nod> I adopted a similar versioning scheme for libc++ for the same reasons. ;-)

#define _LIBCPP_VERSION 1000

There's room for 1000 minor versions, and major versions come in multiples of 1000.  Kudo's go to Nick Kledzik for this.

-Howard





More information about the cfe-dev mailing list