Go to the documentation of this file.
23 #define GCC_CHECK_VERSION(major, minor) \
24 (defined(__GNUC__) && \
25 (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
28 #define GCC_VERSION (__GNUC__ * 10000 \
29 + __GNUC_MINOR__ * 100 \
30 + __GNUC_PATCHLEVEL__)
36 # define CLANG_VERSION (__clang_major__ * 10000 \
37 + __clang_minor__ * 100 \
38 + __clang_patchlevel__)
39 # if __clang_major__ < 3
40 # error Sorry, your clang version is too old. You need at least version 3.1.
42 #elif defined(__GNUC__)
43 # if !GCC_CHECK_VERSION(4,6)
44 # error Sorry, your gcc version is too old. You need at least version 4.6.
47 # warning Untested compiler. Use at your own risk!
50 #if GCC_CHECK_VERSION(4,0)
54 #define gcc_const __attribute__((const))
55 #define gcc_deprecated __attribute__((deprecated))
56 #define gcc_may_alias __attribute__((may_alias))
57 #define gcc_malloc __attribute__((malloc))
58 #define gcc_noreturn __attribute__((noreturn))
59 #define gcc_packed __attribute__((packed))
60 #define gcc_printf(a,b) __attribute__((format(printf, a, b)))
61 #define gcc_pure __attribute__((pure))
62 #define gcc_sentinel __attribute__((sentinel))
63 #define gcc_unused __attribute__((unused))
64 #define gcc_warn_unused_result __attribute__((warn_unused_result))
66 #define gcc_nonnull(...) __attribute__((nonnull(__VA_ARGS__)))
67 #define gcc_nonnull_all __attribute__((nonnull))
69 #define gcc_likely(x) __builtin_expect (!!(x), 1)
70 #define gcc_unlikely(x) __builtin_expect (!!(x), 0)
72 #define gcc_aligned(n) __attribute__((aligned(n)))
74 #define gcc_visibility_hidden __attribute__((visibility("hidden")))
75 #define gcc_visibility_default __attribute__((visibility("default")))
77 #define gcc_always_inline __attribute__((always_inline))
84 #define gcc_deprecated
89 #define gcc_printf(a,b)
93 #define gcc_warn_unused_result
95 #define gcc_nonnull(...)
96 #define gcc_nonnull_all
98 #define gcc_likely(x) (x)
99 #define gcc_unlikely(x) (x)
101 #define gcc_aligned(n)
103 #define gcc_visibility_hidden
104 #define gcc_visibility_default
106 #define gcc_always_inline inline
110 #if GCC_CHECK_VERSION(4,3)
112 #define gcc_hot __attribute__((hot))
113 #define gcc_cold __attribute__((cold))
122 #if GCC_CHECK_VERSION(4,6) && !defined(__clang__)
123 #define gcc_flatten __attribute__((flatten))
130 #define gcc_restrict restrict
131 #elif GCC_CHECK_VERSION(4,0)
133 #define gcc_restrict __restrict__
141 #if defined(__cplusplus)
144 #if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
149 #if defined(__clang__) || GCC_CHECK_VERSION(4,8)
150 #define gcc_alignas(T, fallback) alignas(T)
152 #define gcc_alignas(T, fallback) gcc_aligned(fallback)
157 #ifndef __has_feature
159 #define __has_feature(x) 0
162 #if __has_feature(attribute_unused_on_fields)
163 #define gcc_unused_field gcc_unused
165 #define gcc_unused_field
168 #if defined(__GNUC__) || defined(__clang__)
169 #define gcc_unreachable() __builtin_unreachable()
171 #define gcc_unreachable()