summaryrefslogtreecommitdiff
path: root/ext/bigdecimal/static_assert.h
blob: 9295729bf6a61c5ffa4f60d6d43da8fb4f2df587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef BIGDECIMAL_STATIC_ASSERT_H
#define BIGDECIMAL_STATIC_ASSERT_H

#include "feature.h"

#ifdef HAVE_RUBY_INTERNAL_STATIC_ASSERT_H
# include <ruby/internal/static_assert.h>
#endif

#ifdef RBIMPL_STATIC_ASSERT
# define STATIC_ASSERT RBIMPL_STATIC_ASSERT
#endif

#ifndef STATIC_ASSERT
# /* The following section is copied from CRuby's static_assert.h */

# if defined(__cplusplus) && defined(__cpp_static_assert)
#  /* https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations */
#  define BIGDECIMAL_STATIC_ASSERT0 static_assert

# elif defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER >= 1600
#  define BIGDECIMAL_STATIC_ASSERT0 static_assert

# elif defined(__INTEL_CXX11_MODE__)
#  define BIGDECIMAL_STATIC_ASSERT0 static_assert

# elif defined(__cplusplus) && __cplusplus >= 201103L
#  define BIGDECIMAL_STATIC_ASSERT0 static_assert

# elif defined(__cplusplus) && __has_extension(cxx_static_assert)
#  define BIGDECIMAL_STATIC_ASSERT0 __extension__ static_assert

# elif defined(__STDC_VERSION__) && __has_extension(c_static_assert)
#  define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert

# elif defined(__STDC_VERSION__) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#  define BIGDECIMAL_STATIC_ASSERT0 __extension__ _Static_assert
#endif

# if defined(__DOXYGEN__)
#  define STATIC_ASSERT static_assert

# elif defined(BIGDECIMAL_STATIC_ASSERT0)
#  define STATIC_ASSERT(name, expr) \
    BIGDECIMAL_STATIC_ASSERT0(expr, #name ": " #expr)

# else
#  define STATIC_ASSERT(name, expr) \
    typedef int static_assert_ ## name ## _check[1 - 2 * !(expr)]
# endif
#endif /* STATIC_ASSERT */


#endif /* BIGDECIMAL_STATIC_ASSERT_H */