Skip to content

Commit 33c08a2

Browse files
committed
Guard IS_ENABLED() self-test behind C11
_Static_assert is C11; MSVC's default C mode (used by Python's setuptools to build the wheel) rejects it at file scope, which broke the Windows wheel build. Gate the self-test on __STDC_VERSION__ >= 201112L. The IS_ENABLED() macro needs only a standard preprocessor, so pre-C11 builds lose nothing. Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
1 parent 0f6dbaa commit 33c08a2

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎src/utils.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@
1212

1313
#include <utils/utils.h>
1414

15+
/*
16+
* _Static_assert is C11. Pre-C11 compilers reject it at file scope (notably
17+
* MSVC's default C mode, which Python's setuptools uses to build the wheel).
18+
* Gate the self-test on C11; the IS_ENABLED() macro itself needs only a
19+
* standard preprocessor, so skipping the assert loses nothing on those builds.
20+
*/
21+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
1522
#define _IS_ENABLED_SELFTEST_ON 1
1623
_Static_assert(IS_ENABLED(_IS_ENABLED_SELFTEST_ON) == 1,
1724
"IS_ENABLED(): defined-as-1 flag must evaluate to 1");
1825
_Static_assert(IS_ENABLED(_IS_ENABLED_SELFTEST_OFF) == 0,
1926
"IS_ENABLED(): undefined flag must evaluate to 0");
2027
#undef _IS_ENABLED_SELFTEST_ON
28+
#endif
2129

2230
__weak uint32_t rand_u32(void)
2331
{

0 commit comments

Comments
 (0)