diff --git a/include/assert.h b/include/assert.h index 16c4979..74ab2cd 100644 --- a/include/assert.h +++ b/include/assert.h @@ -40,4 +40,9 @@ extern FOUNDATION_LIBC_NORETURN void foundation_libc_assert(char const * asserti #error "bad definition of FOUNDATION_LIBC_ASSERT_DEFAULT!" #endif +#if !defined(__cplusplus) +#undef static_assert +#define static_assert FOUNDATION_LIBC_STATIC_ASSERT +#endif + #endif diff --git a/include/foundation/builtins.h b/include/foundation/builtins.h index e95803e..a5b57b9 100644 --- a/include/foundation/builtins.h +++ b/include/foundation/builtins.h @@ -12,6 +12,8 @@ #define FOUNDATION_LIBC_ASSERT FOUNDATION_LIBC_ASSERT_DEFAULT #endif +#define FOUNDATION_LIBC_STATIC_ASSERT _Static_assert + #if defined(__clang__) #define FOUNDATION_LIBC_NORETURN __attribute__((__noreturn__)) diff --git a/test/src/assert-validator.c b/test/src/assert-validator.c index b75ca55..db1f492 100644 --- a/test/src/assert-validator.c +++ b/test/src/assert-validator.c @@ -23,3 +23,7 @@ void assert_ok(void) { void assert_bad(void) { assert(0); } + +void assert_static(void) { + static_assert(sizeof(int) == sizeof(int), "int size check"); +}