macros: Fix Clang attribute detection

For attributes we have to use __has_attribute().

https://bugzilla.gnome.org/show_bug.cgi?id=761843
This commit is contained in:
Emmanuele Bassi 2016-02-10 22:37:41 +00:00
parent c7f540b9e9
commit 1964a8726b

View File

@ -91,6 +91,10 @@
#endif #endif
/* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html */ /* Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html */
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_feature #ifndef __has_feature
#define __has_feature(x) 0 #define __has_feature(x) 0
#endif #endif
@ -100,7 +104,7 @@
#endif #endif
#if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ #if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
(defined(__clang__) && __has_feature(__alloc_size__)) (defined(__clang__) && __has_attribute(__alloc_size__))
#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) #define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) #define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
#else #else