Go to the documentation of this file.
3 #ifndef GIRARA_MACROS_H
4 #define GIRARA_MACROS_H
6 #ifndef __has_attribute
7 #define __has_attribute(x) 0
11 #define __has_builtin(x) 0
14 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
15 # define GIRARA_GNUC_CHECK(maj, min) \
16 (((__GNUC__ << 20) + (__GNUC_MINOR__ << 10)) >= (((maj) << 20) + ((min) << 10)))
18 # define GIRARA_GNUC_CHECK(maj, min) 0
22 # if GIRARA_GNUC_CHECK(2, 5) || defined(__clang__)
23 # define GIRARA_PRINTF(format_idx, arg_idx) \
24 __attribute__((__format__ (__printf__, format_idx, arg_idx)))
26 # define GIRARA_PRINTF(format_idx, arg_idx)
31 # if defined(__GNUC__) || defined(__clang__)
32 # define GIRARA_UNUSED(x) UNUSED_ ## x __attribute__((unused))
33 # elif defined(__LCLINT__)
34 # define GIRARA_UNUSED(x) x
36 # define GIRARA_UNUSED(x) x
41 # if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
42 # define GIRARA_HIDDEN __attribute__((visibility("hidden")))
43 # elif defined(__SUNPRO_C)
44 # define GIRARA_HIDDEN __hidden
46 # define GIRARA_HIDDEN
50 #ifndef GIRARA_VISIBLE
51 # if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
52 # define GIRARA_VISIBLE __attribute__((visibility("default")))
54 # define GIRARA_VISIBLE
58 #ifndef GIRARA_DEPRECATED
59 # if defined(__GNUC__) || __has_attribute(deprecated)
60 # define GIRARA_DEPRECATED(x) x __attribute__((deprecated))
61 # define GIRARA_DEPRECATED_ __attribute__((deprecated))
63 # define GIRARA_DEPRECATED(x) x
64 # define GIRARA_DEPRECATED_
68 #ifndef GIRARA_ALLOC_SIZE
69 # if (!defined(__clang__) && GIRARA_GNUC_CHECK(4, 3)) || \
70 (defined(__clang__) && __has_attribute(__alloc_size__))
71 # define GIRARA_ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
73 # define GIRARA_ALLOC_SIZE(x)
77 #ifndef GIRARA_DO_PRAGMA
78 # if defined(__GNUC__) || defined(__clang__)
79 # define GIRARA_DO_PRAGMA(x) _Pragma(#x)
81 # define GIRARA_DO_PRAGMA(x)
85 #ifndef GIRARA_IGNORE_DEPRECATED
86 # define GIRARA_IGNORE_DEPRECATED \
87 GIRARA_DO_PRAGMA(GCC diagnostic push) \
88 GIRARA_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
91 #ifndef GIRARA_UNIGNORE
92 # define GIRARA_UNIGNORE \
93 GIRARA_DO_PRAGMA(GCC diagnostic pop)