Ruby: include/ruby/internal/static_assert.h Source File

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

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>
24#include "ruby/internal/has/extension.h"
25#include "ruby/internal/compiler_since.h"
26
28#if defined(__cplusplus) && defined(__cpp_static_assert)
29# /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
30# define RBIMPL_STATIC_ASSERT0 static_assert
31
32#elif defined(__cplusplus) && RBIMPL_COMPILER_SINCE(MSVC, 16, 0, 0)
33# define RBIMPL_STATIC_ASSERT0 static_assert
34
35#elif defined(__INTEL_CXX11_MODE__)
36# define RBIMPL_STATIC_ASSERT0 static_assert
37
38#elif defined(__cplusplus) && __cplusplus >= 201103L
39# define RBIMPL_STATIC_ASSERT0 static_assert
40
41#elif defined(__cplusplus) && RBIMPL_HAS_EXTENSION(cxx_static_assert)
42# define RBIMPL_STATIC_ASSERT0 __extension__ static_assert
43
44#elif defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__
45# define RBIMPL_STATIC_ASSERT0 __extension__ static_assert
46
47#elif defined(__STDC_VERSION__) && RBIMPL_HAS_EXTENSION(c_static_assert)
48# define RBIMPL_STATIC_ASSERT0 __extension__ _Static_assert
49
50#elif defined(__STDC_VERSION__) && RBIMPL_COMPILER_SINCE(GCC, 4, 6, 0)
51# define RBIMPL_STATIC_ASSERT0 __extension__ _Static_assert
52
53#elif defined(static_assert)
54# /* Take <assert.h> definition */
55# define RBIMPL_STATIC_ASSERT0 static_assert
56#endif
65#if defined(__DOXYGEN__)
66# define RBIMPL_STATIC_ASSERT static_assert
67
68#elif defined(RBIMPL_STATIC_ASSERT0)
69# define RBIMPL_STATIC_ASSERT(name, expr) \
70 RBIMPL_STATIC_ASSERT0(expr, # name ": " # expr)
71
72#else
73# define RBIMPL_STATIC_ASSERT(name, expr) \
74 typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
75#endif
76
77#endif /* RBIMPL_STATIC_ASSERT_H */
assert.h
compiler_since.h
Defines RBIMPL_COMPILER_SINCE.
extension.h
Defines RBIMPL_HAS_EXTENSION.