pub struct Predef {
pub std: Std,
pub gnu_extensions: bool,
pub gnu89_inline: bool,
pub gnuc: GnucVersion,
pub opt_level: OptLevel,
pub hosted: bool,
pub pic: Pic,
pub timestamp: Timestamp,
pub glibc_minor: Option<u32>,
pub defines: Vec<String>,
pub undefines: Vec<String>,
}Expand description
Everything the predefined set is built from that is not the target.
Fields§
§std: StdThe dialect, which decides __STDC_VERSION__.
gnu_extensions: boolWhether the GNU extensions are on, which is -std=gnu23 rather than -std=c23. It
decides __STRICT_ANSI__ and the unarmoured linux and unix macros.
gnu89_inline: boolWhether the unit is under GNU’s reading of inline, which is -fgnu89-inline. It decides
which of __GNUC_GNU_INLINE__ and __GNUC_STDC_INLINE__ is defined, and the C89 dialects
are under that reading whatever it says.
gnuc: GnucVersionThe GCC release claimed.
opt_level: OptLevelDecides __OPTIMIZE__, __OPTIMIZE_SIZE__ and __NO_INLINE__.
hosted: boolWhether there is a standard library, which is -ffreestanding turned around.
pic: PicWhich link the output is for, from -fPIC and -fPIE. It decides __PIE__, since
__PIC__ is defined either way and says only that there are no absolute addresses.
timestamp: Timestamp__DATE__ and __TIME__.
glibc_minor: Option<u32>The glibc release the headers are, as the minor number alone, when they are ours.
__GLIBC_MINOR__ and nothing else: __GLIBC__ is 2 in the tree itself, which is how Zig’s
own patched features.h has it, and a version the compiler supplied and a version the
header supplied would be two answers to one question.
defines: Vec<String>-D in command line order. FOO means FOO=1, as GCC has it.
undefines: Vec<String>-U in command line order, applied after the defines.
Implementations§
Source§impl Predef
impl Predef
Sourcepub fn for_options(opts: &Options) -> Predef
pub fn for_options(opts: &Options) -> Predef
The set the command line asked for.
The mapping lives here rather than in the driver because it is the definition of what
each flag means to the macro set, and the driver’s job is to parse a command line, not
to know that -ffreestanding is __STDC_HOSTED__ being zero.