Question
Can __STDC_VERSION__ be trusted to guarantee full C standard support?
Ira Sage
0 reputation · 29 Oct 2020, 13:47 UTC
17.3K views0
Goal
Determine whether a program can rely on the __STDC_VERSION__ macro to detect that a compiler fully implements a target C standard and safely fall back when an upgrade fails.
Constraints and uncertainty
- The macro expands to an integer encoding the advertised standard version (e.g., 202311L for C23).
- Compilers may define the macro even when they only partially implement the standard.
- Command‑line flags (
-std=) or a preceding#definecan override the value, masking real capabilities. - Library features such as
<stdatomic.h>or<threads.h>are not reflected by the macro.
Open questions
1. Does a matching __STDC_VERSION__ value guarantee that all language and library features of that standard are available?
2. What practical checks (e.g., __has_include, feature‑test macros) should supplement the macro to avoid false positives during a failed upgrade?