infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
compat_c23.h
Go to the documentation of this file.
1
37
#pragma once
38
#include <stdbool.h>
39
#include <stddef.h>
50
#ifndef nullptr
51
#define nullptr ((void *)0)
52
#endif
62
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(_MSC_VER) && _MSC_VER >= 1900)
63
#include <assert.h>
64
#ifndef static_assert
65
#define static_assert(cond, msg) _Static_assert(cond, msg)
66
#endif
67
#endif
80
#if defined(__has_c_attribute)
81
#define COMPAT_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
82
#else
83
#define COMPAT_HAS_C_ATTRIBUTE(x) 0
84
#endif
99
#if COMPAT_HAS_C_ATTRIBUTE(nodiscard)
100
#define c23_nodiscard [[nodiscard]]
101
#elif defined(__GNUC__) || defined(__clang__)
102
#define c23_nodiscard __attribute__((warn_unused_result))
103
#elif defined(_MSC_VER)
104
#define c23_nodiscard _Check_return_
105
#else
106
#define c23_nodiscard
107
#endif
122
#if COMPAT_HAS_C_ATTRIBUTE(deprecated)
123
#define c23_deprecated [[deprecated]]
124
#elif defined(__GNUC__) || defined(__clang__)
125
#define c23_deprecated __attribute__((deprecated))
126
#elif defined(_MSC_VER)
127
#define c23_deprecated __declspec(deprecated)
128
#else
129
#define c23_deprecated
130
#endif
145
#if COMPAT_HAS_C_ATTRIBUTE(fallthrough)
146
#define c23_fallthrough [[fallthrough]]
147
#elif defined(__GNUC__) || defined(__clang__)
148
#define c23_fallthrough __attribute__((fallthrough))
149
#else
150
#define c23_fallthrough
151
#endif
166
#if COMPAT_HAS_C_ATTRIBUTE(maybe_unused)
167
#define c23_maybe_unused [[maybe_unused]]
168
#elif defined(__GNUC__) || defined(__clang__)
169
#define c23_maybe_unused __attribute__((unused))
170
#else
171
#define c23_maybe_unused
172
#endif
src
common
compat_c23.h
Generated by
1.9.8