diff options
Diffstat (limited to 'src/sciteco.h')
| -rw-r--r-- | src/sciteco.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sciteco.h b/src/sciteco.h index 388d6c4..2e6ced2 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -117,6 +117,16 @@ extern volatile sig_atomic_t teco_interrupted; */ G_DEFINE_AUTOPTR_CLEANUP_FUNC(FILE, fclose); +/** + * A "safe" compile-time assertion, which also passes if the expression is not constant. + * + * Can be useful since different compilers have different ideas about what's a constant expression. + * In particular GCC does not treat `static const` objects as constant (in the way it qualifies + * for _Static_assert()), while constexpr is only available since C23. + */ +#define TECO_ASSERT_SAFE(EXPR) \ + G_STATIC_ASSERT(!__builtin_constant_p(EXPR) || (EXPR)) + /* * BEWARE DRAGONS! */ |
