Ruby 3.5.0dev (2025-02-22 revision 412997300569c1853c09813e4924b6df3d7e8669)
static_assert.h
Go to the documentation of this file.
1#ifndef RBIMPL_STATIC_ASSERT_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_STATIC_ASSERT_H
23#include <assert.h>
27
29#if defined(__cplusplus) && defined(__cpp_static_assert)
30# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
31# define RBIMPL_STATIC_ASSERT0 static_assert
32
33#elif defined(__cplusplus) && RBIMPL_COMPILER_SINCE(MSVC, 16, 0, 0)
34# define RBIMPL_STATIC_ASSERT0 static_assert
35
36#elif defined(__INTEL_CXX11_MODE__)
37# define RBIMPL_STATIC_ASSERT0 static_assert
38
39#elif defined(__cplusplus) && __cplusplus >= 201103L
40# define RBIMPL_STATIC_ASSERT0 static_assert
41
42#elif defined(__cplusplus) && RBIMPL_HAS_EXTENSION(cxx_static_assert)
43# define RBIMPL_STATIC_ASSERT0 __extension__ static_assert
44
45#elif defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__
46# define RBIMPL_STATIC_ASSERT0 __extension__ static_assert
47
48#elif defined(__STDC_VERSION__) && RBIMPL_HAS_EXTENSION(c_static_assert)
49# define RBIMPL_STATIC_ASSERT0 __extension__ _Static_assert
50
51#elif defined(__STDC_VERSION__) && RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0)
52# define RBIMPL_STATIC_ASSERT0 __extension__ _Static_assert
53
54#elif defined(static_assert)
55# /* Take <assert.h> definition */
56# define RBIMPL_STATIC_ASSERT0 static_assert
57#endif
66#if defined(__DOXYGEN__)
67# define RBIMPL_STATIC_ASSERT static_assert
68
69#elif defined(RBIMPL_STATIC_ASSERT0)
70# define RBIMPL_STATIC_ASSERT(name, expr) \
71 RBIMPL_STATIC_ASSERT0(expr, # name ": " # expr)
72
73#else
74# define RBIMPL_STATIC_ASSERT(name, expr) \
75 RBIMPL_ATTR_MAYBE_UNUSED() typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
76#endif
77
78#endif /* RBIMPL_STATIC_ASSERT_H */
Defines RBIMPL_COMPILER_SINCE.
Defines RBIMPL_HAS_EXTENSION.
Defines RBIMPL_ATTR_MAYBE_UNUSED.