girara
Toggle main menu visibility
Loading...
Searching...
No Matches
macros.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: Zlib */
2
3
#ifndef GIRARA_MACROS_H
4
#define GIRARA_MACROS_H
5
6
#ifndef __has_attribute
7
#define __has_attribute(x) 0
8
#endif
9
10
#ifndef __has_builtin
11
#define __has_builtin(x) 0
12
#endif
13
14
#if defined(__GNUC__) && defined(__GNUC_MINOR__)
15
#define GIRARA_GNUC_CHECK(maj, min) (((__GNUC__ << 20) + (__GNUC_MINOR__ << 10)) >= (((maj) << 20) + ((min) << 10)))
16
#else
17
#define GIRARA_GNUC_CHECK(maj, min) 0
18
#endif
19
20
#ifndef GIRARA_PRINTF
21
#if GIRARA_GNUC_CHECK(2, 5) || defined(__clang__)
22
#define GIRARA_PRINTF(format_idx, arg_idx) __attribute__((__format__(__printf__, format_idx, arg_idx)))
23
#else
24
#define GIRARA_PRINTF(format_idx, arg_idx)
25
#endif
26
#endif
27
28
#ifndef GIRARA_UNUSED
29
#if defined(__GNUC__) || defined(__clang__)
30
#define GIRARA_UNUSED(x) UNUSED_##x __attribute__((unused))
31
#elif defined(__LCLINT__)
32
#define GIRARA_UNUSED(x)
/*@unused@*/
x
33
#else
34
#define GIRARA_UNUSED(x) x
35
#endif
36
#endif
37
38
#ifndef GIRARA_HIDDEN
39
#if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
40
#define GIRARA_HIDDEN __attribute__((visibility("hidden")))
41
#elif defined(__SUNPRO_C)
42
#define GIRARA_HIDDEN __hidden
43
#else
44
#define GIRARA_HIDDEN
45
#endif
46
#endif
47
48
#ifndef GIRARA_VISIBLE
49
#if GIRARA_GNUC_CHECK(4, 0) || __has_attribute(visibility)
50
#define GIRARA_VISIBLE __attribute__((visibility("default")))
51
#else
52
#define GIRARA_VISIBLE
53
#endif
54
#endif
55
56
#ifndef GIRARA_DEPRECATED
57
#if defined(__GNUC__) || __has_attribute(deprecated)
58
#define GIRARA_DEPRECATED(x) x __attribute__((deprecated))
59
#define GIRARA_DEPRECATED_ __attribute__((deprecated))
60
#else
61
#define GIRARA_DEPRECATED(x) x
62
#define GIRARA_DEPRECATED_
63
#endif
64
#endif
65
66
#ifndef GIRARA_ALLOC_SIZE
67
#if (!defined(__clang__) && GIRARA_GNUC_CHECK(4, 3)) || (defined(__clang__) && __has_attribute(__alloc_size__))
68
#define GIRARA_ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__)))
69
#else
70
#define GIRARA_ALLOC_SIZE(x)
71
#endif
72
#endif
73
74
#ifndef GIRARA_DO_PRAGMA
75
#if defined(__GNUC__) || defined(__clang__)
76
#define GIRARA_DO_PRAGMA(x) _Pragma(#x)
77
#else
78
#define GIRARA_DO_PRAGMA(x)
79
#endif
80
#endif
81
82
#ifndef GIRARA_IGNORE_DEPRECATED
83
#define GIRARA_IGNORE_DEPRECATED \
84
GIRARA_DO_PRAGMA(GCC diagnostic push) \
85
GIRARA_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
86
#endif
87
88
#ifndef GIRARA_UNIGNORE
89
#define GIRARA_UNIGNORE GIRARA_DO_PRAGMA(GCC diagnostic pop)
90
#endif
91
92
#endif
girara
macros.h
Generated by
1.17.0