diff options
Diffstat (limited to 'src/prelude.h')
-rw-r--r-- | src/prelude.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/prelude.h b/src/prelude.h index de89a6c..51f1505 100644 --- a/src/prelude.h +++ b/src/prelude.h @@ -77,23 +77,26 @@ /** _Bool => bool, true, false */ #include <stdbool.h> -/** - * C23 deprecates `noreturn void` in favour of `[[noreturn]] void`, so we expose - * _noreturn instead with the other attributes in "bfs.h". - */ -// #include <stdnoreturn.h> - /** Part of <threads.h>, but we don't use anything else from it. */ #define thread_local _Thread_local +/** Get the type of an expression. */ +#define typeof __typeof__ +/** Get the unqualified type of an expression. */ +#define typeof_unqual __typeof_unqual__ + #endif // !C23 -// Feature detection +// Future C standard backports -// https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute -#ifndef __has_attribute -# define __has_attribute(attr) false -#endif +/** + * 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-builtin #ifndef __has_builtin @@ -126,5 +129,8 @@ #if __has_feature(thread_sanitizer) && !defined(__SANITIZE_THREAD__) # define __SANITIZE_THREAD__ true #endif +#if __has_feature(type_sanitizer) && !defined(__SANITIZE_TYPE__) +# define __SANITIZE_TYPE__ true +#endif #endif // BFS_PRELUDE_H |