girara
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
macros.h
Go to the documentation of this file.
1 /* See LICENSE file for license and copyright information */
2 
3 #ifndef GIRARA_MACROS_H
4 #define GIRARA_MACROS_H
5 
6 #ifndef GIRARA_PRINTF
7 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) || defined(__clang__)
8 # define GIRARA_PRINTF(format_idx, arg_idx) \
9  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
10 # else
11 # define GIRARA_PRINTF(format_idx, arg_idx)
12 # endif
13 #endif
14 
15 #ifndef GIRARA_UNUSED
16 # if defined(__GNUC__) || defined(__clang__)
17 # define GIRARA_UNUSED(x) UNUSED_ ## x __attribute__((unused))
18 # elif defined(__LCLINT__)
19 # define GIRARA_UNUSED(x) /*@unused@*/ x
20 # else
21 # define GIRARA_UNUSED(x) x
22 # endif
23 #endif
24 
25 #ifndef GIRARA_HIDDEN
26 # if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
27 # define GIRARA_HIDDEN __attribute__((visibility("hidden")))
28 # elif defined(__SUNPRO_C)
29 # define GIRARA_HIDDEN __hidden
30 # else
31 # define GIRARA_HIDDEN
32 # endif
33 #endif
34 
35 #ifndef GIRARA_DEPRECATED
36 # if defined(__GNUC__)
37 # define GIRARA_DEPRECATED(x) x __attribute__((deprecated))
38 # define GIRARA_DEPRECATED_ __attribute__((deprecated))
39 # else
40 # define GIRARA_DEPRECATED(x) x
41 # define GIRARA_DEPRECATED_
42 # endif
43 #endif
44 
45 #ifndef GIRARA_ALLOC_SIZE
46 # if defined(__GNUC__)
47 # define GIRARA_ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
48 # else
49 # define GIRARA_ALLOC_SIZE(x)
50 # endif
51 #endif
52 
53 #ifndef GIRARA_DO_PRAGMA
54 # if defined(__GNUC__) || defined(__clang__)
55 # define GIRARA_DO_PRAGMA(x) _Pragma(#x)
56 # else
57 # define GIRARA_DO_PRAGMA(x)
58 # endif
59 #endif
60 
61 #ifndef GIRARA_IGNORE_DEPRECATED
62 # define GIRARA_IGNORE_DEPRECATED \
63  GIRARA_DO_PRAGMA(GCC diagnostic push) \
64  GIRARA_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
65 #endif
66 
67 #ifndef GIRARA_UNIGNORE
68 # define GIRARA_UNIGNORE \
69  GIRARA_DO_PRAGMA(GCC diagnostic pop)
70 #endif
71 
72 #endif