static_assert.h 610 B

123456789101112131415161718192021
  1. #ifndef AL_STATIC_ASSERT_H
  2. #define AL_STATIC_ASSERT_H
  3. #include <assert.h>
  4. #ifndef static_assert
  5. #ifdef HAVE_C11_STATIC_ASSERT
  6. #define static_assert _Static_assert
  7. #else
  8. #define CTASTR2(_pre,_post) _pre##_post
  9. #define CTASTR(_pre,_post) CTASTR2(_pre,_post)
  10. #if defined(__COUNTER__)
  11. #define static_assert(_cond, _msg) typedef struct { int CTASTR(static_assert_failed_at_line_,__LINE__) : !!(_cond); } CTASTR(static_assertion_,__COUNTER__)
  12. #else
  13. #define static_assert(_cond, _msg) struct { int CTASTR(static_assert_failed_at_line_,__LINE__) : !!(_cond); }
  14. #endif
  15. #endif
  16. #endif
  17. #endif /* AL_STATIC_ASSERT_H */