pub enum Std {
C89,
C99,
C11,
C17,
C23,
C2y,
}Expand description
Which C the source is written in.
The GNU variants are the same language with __STRICT_ANSI__ left undefined, so the
dialect and the extension question are two fields rather than ten variants.
Variants§
C89
-std=c89, and -ansi.
C99
-std=c99.
C11
-std=c11.
C17
-std=c17, which is C11 with the defect reports applied.
C23
-std=c23. The default, matching current GCC.
C2y
-std=c2y, the draft after C23, which gcc 16 takes and reports as 202500L. It is C23
with whatever the next standard has added so far, and the one addition anything here reads
yet is the four unsigned absolute value functions under their plain names.
Implementations§
Source§impl Std
impl Std
Sourcepub const fn stdc_version(self) -> Option<&'static str>
pub const fn stdc_version(self) -> Option<&'static str>
What __STDC_VERSION__ says, which C89 does not define at all.
Sourcepub const fn has_c11(self) -> bool
pub const fn has_c11(self) -> bool
Whether this dialect has _Atomic, _Thread_local and the rest of C11.
Sourcepub fn from_flag(name: &str) -> Option<(Std, bool)>
pub fn from_flag(name: &str) -> Option<(Std, bool)>
Reads a -std= argument, and says whether the GNU extensions came with it.
Every alias GCC takes is here, including the iso9899 spellings and the year based
ones, because a build system that passes -std=iso9899:1999 is passing what its
author tested against and rejecting it helps nobody. An unknown dialect is None
rather than a guess, since guessing means compiling a different language than the one
asked for.