infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
compat_c23.h
Go to the documentation of this file.
1
39
#pragma once
40
41
#include <stdbool.h>
42
#include <stddef.h>
43
54
#ifndef nullptr
55
#define nullptr ((void *)0)
56
#endif
57
67
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(_MSC_VER) && _MSC_VER >= 1900)
68
#include <assert.h>
69
#ifndef static_assert
70
#define static_assert(cond, msg) _Static_assert(cond, msg)
71
#endif
72
#endif
73
86
#if defined(__has_c_attribute)
87
#define COMPAT_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
88
#else
89
#define COMPAT_HAS_C_ATTRIBUTE(x) 0
90
#endif
91
106
#if COMPAT_HAS_C_ATTRIBUTE(nodiscard)
107
#define c23_nodiscard [[nodiscard]]
108
#elif defined(__GNUC__) || defined(__clang__)
109
#define c23_nodiscard __attribute__((warn_unused_result))
110
#elif defined(_MSC_VER)
111
#define c23_nodiscard _Check_return_
112
#else
113
#define c23_nodiscard
114
#endif
115
130
#if COMPAT_HAS_C_ATTRIBUTE(deprecated)
131
#define c23_deprecated [[deprecated]]
132
#elif defined(__GNUC__) || defined(__clang__)
133
#define c23_deprecated __attribute__((deprecated))
134
#elif defined(_MSC_VER)
135
#define c23_deprecated __declspec(deprecated)
136
#else
137
#define c23_deprecated
138
#endif
139
154
#if COMPAT_HAS_C_ATTRIBUTE(fallthrough)
155
#define c23_fallthrough [[fallthrough]]
156
#elif defined(__GNUC__) || defined(__clang__)
157
#define c23_fallthrough __attribute__((fallthrough))
158
#else
159
#define c23_fallthrough
160
#endif
161
176
#if COMPAT_HAS_C_ATTRIBUTE(maybe_unused)
177
#define c23_maybe_unused [[maybe_unused]]
178
#elif defined(__GNUC__) || defined(__clang__)
179
#define c23_maybe_unused __attribute__((unused))
180
#else
181
#define c23_maybe_unused
182
#endif
183
src
common
compat_c23.h
Generated by
1.9.8