pub enum Standard {
C89,
C99,
C11,
C17,
C23,
}Expand description
Which revision of the C standard to accept.
The variants are ordered, so a feature is gated by comparing: a construct
C11 introduced is accepted when standard >= Standard::C11. C17 is C11
with a different __STDC_VERSION__ and adds nothing else.
Variants§
C89
ISO/IEC 9899:1990, the standard everyone still calls C89.
C90 is the ISO republication of ANSI X3.159-1989 with no technical
change, so c89! and c90! are one entry point under two names.
C99
ISO/IEC 9899:1999.
C11
ISO/IEC 9899:2011.
C17
ISO/IEC 9899:2018.
C23
ISO/IEC 9899:2024.
Implementations§
Source§impl Standard
impl Standard
Sourcepub fn stdc_version(self) -> Option<&'static str>
pub fn stdc_version(self) -> Option<&'static str>
The value of __STDC_VERSION__ for this revision, or None where the
revision has none.
C89 as published had no __STDC_VERSION__ at all — Amendment 1 added
it in 1995 — so c89! and gnu89! leave the macro undefined, which is
what gcc -std=c89 does and what a program testing
#ifdef __STDC_VERSION__ is looking for. __STDC__ is still 1.
Source§impl Standard
impl Standard
Sourcepub fn macro_name(self) -> &'static str
pub fn macro_name(self) -> &'static str
The macro that selects this standard, as a diagnostic names it.
Sourcepub fn macro_name_in(self, dialect: Dialect) -> &'static str
pub fn macro_name_in(self, dialect: Dialect) -> &'static str
The macro that selects this standard in dialect.
Sourcepub fn macro_names_in(self, dialect: Dialect) -> &'static [&'static str]
pub fn macro_names_in(self, dialect: Dialect) -> &'static [&'static str]
Every name the macro that selects this standard in dialect may be
written with, without the !.
Two of them only for C89, which has two names and one entry point; the
point of the list is that the search for an invocation
in the crate’s sources knows what to look for, and c90! { … } has to be
found as readily as c89! { … }.
Sourcepub fn include_macro_names_in(self, dialect: Dialect) -> &'static [&'static str]
pub fn include_macro_names_in(self, dialect: Dialect) -> &'static [&'static str]
The same for the include_…! family, which is one entry point per name
of Standard::macro_names_in.
Sourcepub fn requires(self, what: &str, needed: Standard) -> String
pub fn requires(self, what: &str, needed: Standard) -> String
The message a feature from a newer revision gets in this one.
what is the subject, already quoted where it names a token:
standard.requires("'_Static_assert'", Standard::C11) reads
'_Static_assert' requires C11 or later (this block is c99!). Saying
which macro the block is written with is the point — the fix is to
change the macro, and nothing in the C says which one it is.