Don't assume __STDC_VERSION__ is defined #127

Closed
opened 2026-01-29 20:36:53 +00:00 by claunia · 2 comments
Owner

Originally created by @nemequ on GitHub (Jul 28, 2016).

See https://travis-ci.org/quixdb/squash/jobs/148061907#L1491

Note that this is coming from types.h, so it happens when compiling code using brotli, not necessarily in brotli itself. Even if you don't care about -Wundef in brotli, IMHO it should be possible for people who just want to use brotli to use whatever warning flags they want.

Untested, but this should do the trick:

diff --git a/common/types.h b/common/types.h
index 4b050af..3508d74 100644
--- a/common/types.h
+++ b/common/types.h
@@ -25,7 +25,7 @@ typedef __int64 int64_t;
 #endif  /* defined(_MSC_VER) && (_MSC_VER < 1600) */

 #if (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \
-    (defined(__cplusplus) || __STDC_VERSION__ >= 199901L)
+    (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))
 #include <stdbool.h>
 #define BROTLI_BOOL bool
 #define BROTLI_TRUE true
Originally created by @nemequ on GitHub (Jul 28, 2016). See https://travis-ci.org/quixdb/squash/jobs/148061907#L1491 Note that this is coming from types.h, so it happens when compiling code _using_ brotli, not necessarily in brotli itself. Even if you don't care about `-Wundef` in brotli, IMHO it should be possible for people who just want to use brotli to use whatever warning flags they want. Untested, but this should do the trick: ``` diff diff --git a/common/types.h b/common/types.h index 4b050af..3508d74 100644 --- a/common/types.h +++ b/common/types.h @@ -25,7 +25,7 @@ typedef __int64 int64_t; #endif /* defined(_MSC_VER) && (_MSC_VER < 1600) */ #if (!defined(_MSC_VER) || (_MSC_VER >= 1800)) && \ - (defined(__cplusplus) || __STDC_VERSION__ >= 199901L) + (defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)) #include <stdbool.h> #define BROTLI_BOOL bool #define BROTLI_TRUE true ```
Author
Owner

@nemequ commented on GitHub (Jul 29, 2016):

Closing since #399 fixes this; discussion (if necessary) can take place there.

@nemequ commented on GitHub (Jul 29, 2016): Closing since #399 fixes this; discussion (if necessary) can take place there.
Author
Owner

@eustas commented on GitHub (Jul 29, 2016):

Unguarded __STDC_VERSION__ will be fixed in next encoder/decoder update.

@eustas commented on GitHub (Jul 29, 2016): Unguarded `__STDC_VERSION__` will be fixed in next encoder/decoder update.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#127