Repository navigation
Build headers as ISO C11 - #35
Merged
Merged
Conversation
The shim promises any -std >= c11, but the implementation used empty
initializers, a C23 & GNU extension, & GCC reports __has_c_attribute in
C11 mode, so CHC_NODISCARD & friends expanded to [[...]]. -std=c11
-Wpedantic warns on every use, & -pedantic-errors fails the build: the
new test_c11 stops with 36 errors under GCC 13 before this change.
Use {0}, & only take the [[...]] spellings at C23, falling back to the
GNU attributes otherwise. CHC_FALLTHROUGH gains the GNU spelling so
-Wimplicit-fallthrough stays quiet.
serprex
approved these changes
Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The portability shim says consumers may build under any -std >= c11. Two things break that under -std=c11 -Wpedantic.
= {},(chc__fields) {}), which are a C23 and GNU extension.With -pedantic-errors, the build fails.
Initializers are now {0}. CHC__HAS_ATTR only reports attributes at STDC_VERSION >= 202311L, so earlier modes use the existing GNU spellings. With GCC 11+ that means CHC_NODISCARD becomes warn_unused_result, which a (void) cast does not silence, the same as GCC before 11 and clang already get in C11 mode. CHC_FALLTHROUGH gets a attribute((fallthrough)) fallback, so -Wimplicit-fallthrough stays quiet under -Wextra.
The new test_c11 includes every header with the implementation and promotes -Wpedantic diagnostics to errors. On main it stops with 36 errors under GCC 13 and 14 under clang 14.