diff options
Diffstat (limited to 'src/prelude.h')
-rw-r--r-- | src/prelude.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/prelude.h b/src/prelude.h index 3b1c4e5..1663af6 100644 --- a/src/prelude.h +++ b/src/prelude.h @@ -88,6 +88,15 @@ #endif // !C23 +// Future C standard backports + +/** + * Get the length of an array. + * + * https://www.open-std.org/JTC1/SC22/WG14/www/docs/n3469.htm + */ +#define countof(...) (sizeof(__VA_ARGS__) / sizeof(0[__VA_ARGS__])) + // Feature detection // https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute |