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 "common/infix_config.h"
39#include <infix/infix.h>
40#include <stdbool.h>
41#include <stddef.h>
52#if !defined(nullptr) && !defined(__cplusplus)
53#define nullptr ((void *)0)
54#endif
64#if !defined(__cplusplus) && \
65 ((defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || (defined(INFIX_COMPILER_MSVC) && _MSC_VER >= 1900))
66#include <assert.h>
67#ifndef static_assert
68#define static_assert(cond, msg) _Static_assert(cond, msg)
69#endif
70#endif
83#if defined(__has_c_attribute)
84#define COMPAT_HAS_C_ATTRIBUTE(x) __has_c_attribute(x)
85#else
86#define COMPAT_HAS_C_ATTRIBUTE(x) 0
87#endif
92#define c23_nodiscard INFIX_NODISCARD
107#if COMPAT_HAS_C_ATTRIBUTE(deprecated)
108#define c23_deprecated [[deprecated]]
109#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
110#define c23_deprecated __attribute__((deprecated))
111#elif defined(INFIX_COMPILER_MSVC)
112#define c23_deprecated __declspec(deprecated)
113#else
114#define c23_deprecated
115#endif
130#if COMPAT_HAS_C_ATTRIBUTE(fallthrough)
131#define c23_fallthrough [[fallthrough]]
132#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
133#define c23_fallthrough __attribute__((fallthrough))
134#else
135#define c23_fallthrough
136#endif
151#if COMPAT_HAS_C_ATTRIBUTE(maybe_unused)
152#define c23_maybe_unused [[maybe_unused]]
153#elif defined(INFIX_COMPILER_GCC) || defined(INFIX_COMPILER_CLANG)
154#define c23_maybe_unused __attribute__((unused))
155#else
156#define c23_maybe_unused
157#endif
The public interface for the infix FFI library.
Platform, architecture, and ABI detection macros.