diff options
author | Victor Toso <victortoso@redhat.com> | 2015-08-14 18:24:22 +0200 |
---|---|---|
committer | Frediano Ziglio <fziglio@redhat.com> | 2015-08-20 11:00:35 +0100 |
commit | fa19ebb83f29bfc6fa011239d5fff172282bfe55 (patch) | |
tree | 502d5d9c1c901df8e4c0553ecc4bd98a28f9675f | |
parent | 2cd036e9d42ce9bf053609c9030ee7e2f9c01790 (diff) |
macros: verify if __alloc_size__ works with clang
So we can avoid using using an attribute not supported for the compiler.
warning:
../spice-common/common/mem.h:91:80: warning: unknown attribute
'__alloc_size__' ignored [-Wunknown-attributes]
void *spice_malloc0_n(size_t n_blocks, size_t n_block_bytes)
SPICE_GNUC_MALLOC SPICE_GNUC_ALLOC_SIZE2(1,2);
../spice-common/spice-protocol/spice/macros.h:52:52: note: expanded
from macro 'SPICE_GNUC_ALLOC_SIZE2'
#define SPICE_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
^
-rw-r--r-- | spice/macros.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/spice/macros.h b/spice/macros.h index 180c2b7..034caf7 100644 --- a/spice/macros.h +++ b/spice/macros.h @@ -47,7 +47,8 @@ #define SPICE_GNUC_NULL_TERMINATED #endif -#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) +#if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ + (defined(__clang__) && __has_feature(__alloc_size__)) #define SPICE_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) #define SPICE_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) #else |