From ef5932ab035d37fa26c9a18773285e769b67abcf Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 28 Dec 2023 23:50:39 +0100 Subject: Assert POSIX when __has_include() is available --- cbs.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cbs.h b/cbs.h index 504e96e..aa75101 100644 --- a/cbs.h +++ b/cbs.h @@ -20,6 +20,19 @@ #ifndef C_BUILD_SYSTEM_H #define C_BUILD_SYSTEM_H +/* Assert that the user is building for a supported platform. The only portable + way to check for POSIX is to validate that unistd.h exists. This is only + possible without compiler extensions in C23 (although some compilers support + it as an extension in earlier editions), so people compiling for pre-C23 + might not get this error if on a bad platform, and may end up being a bit + confused. + + It’s just a maybe though, this is nothing more than a sanity check for the + users sake. */ +#if defined(__has_include) && !__has_include() +# error "Non-POSIX platform detected" +#endif + #include #include -- cgit v1.2.3