nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

pstatic_assert.h (1844B)


      1 #ifndef PSTATIC_ASSERT_H
      2 #define PSTATIC_ASSERT_H
      3 
      4 #include <assert.h>
      5 
      6 /* Handle clang */
      7 #ifndef __has_feature
      8   #define __has_feature(x) 0
      9 #endif
     10 
     11 #if defined(static_assert)
     12 #ifndef __static_assert_is_defined
     13 #define __static_assert_is_defined 1
     14 #endif
     15 #endif
     16 
     17 /* Handle static_assert as a keyword in C++ and compiler specifics. */
     18 #if !defined(__static_assert_is_defined)
     19 
     20 #if defined(__cplusplus)
     21 
     22 #if __cplusplus >= 201103L
     23 #define __static_assert_is_defined 1
     24 #elif __has_feature(cxx_static_assert)
     25 #define __static_assert_is_defined 1
     26 #elif defined(_MSC_VER) && (_MSC_VER >= 1600)
     27 #define __static_assert_is_defined 1
     28 #endif
     29 
     30 #else
     31 
     32 #if defined(_MSC_VER) && (_MSC_VER >= 1600)
     33 #define __static_assert_is_defined 1
     34 #elif __has_feature(c_static_assert)
     35 #define static_assert(pred, msg) _Static_assert(pred, msg)
     36 #define __static_assert_is_defined 1
     37 #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
     38 /* In case the clib headers are not compliant. */
     39 #define static_assert(pred, msg) _Static_assert(pred, msg)
     40 #define __static_assert_is_defined 1
     41 #endif
     42 
     43 #endif /* __cplusplus */
     44 #endif /* __static_assert_is_defined */
     45 
     46 
     47 #if !defined(__static_assert_is_defined)
     48 
     49 #define __PSTATIC_ASSERT_CONCAT_(a, b) static_assert_scope_##a##_line_##b
     50 #define __PSTATIC_ASSERT_CONCAT(a, b) __PSTATIC_ASSERT_CONCAT_(a, b)
     51 #ifdef __COUNTER__
     52 #define static_assert(e, msg) enum { __PSTATIC_ASSERT_CONCAT(__COUNTER__, __LINE__) = 1/(!!(e)) }
     53 #else
     54 #include "pstatic_assert_scope.h"
     55 #define static_assert(e, msg) enum { __PSTATIC_ASSERT_CONCAT(__PSTATIC_ASSERT_COUNTER, __LINE__) = 1/(int)(!!(e)) }
     56 #endif
     57 
     58 #define __static_assert_is_defined 1
     59 
     60 #endif /* __static_assert_is_defined */
     61 
     62 #endif /* PSTATIC_ASSERT_H */
     63 
     64 /* Update scope counter outside of include guard. */
     65 #ifdef __PSTATIC_ASSERT_COUNTER
     66 #include "pstatic_assert_scope.h"
     67 #endif