add NIM_STATIC_ASSERT(CHAR_BIT == 8, "") to fail-fast where assumption is violated (#18512)

This commit is contained in:
Timothee Cour 2021-07-18 02:05:35 -07:00 • committed by GitHub
commit 3723140044
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -325,6 +325,9 @@ typedef unsigned char NIM_BOOL; // best effort
#endif #endif
NIM_STATIC_ASSERT(sizeof(NIM_BOOL) == 1, ""); // check whether really needed NIM_STATIC_ASSERT(sizeof(NIM_BOOL) == 1, ""); // check whether really needed
NIM_STATIC_ASSERT(CHAR_BIT == 8, "");
// fail fast for (rare) environments where this doesn't hold, as some implicit
// assumptions would need revisiting (e.g. `uint8` or https://github.com/nim-lang/Nim/pull/18505)
#define NIM_TRUE true #define NIM_TRUE true
#define NIM_FALSE false #define NIM_FALSE false