pub struct Options {
pub standard: Standard,
pub dialect: Dialect,
pub dollar_in_identifiers: bool,
pub include_paths: Vec<PathBuf>,
pub system_include: System,
pub target: TargetModel,
pub target_source: TargetSource,
pub complex: bool,
}Expand description
Knobs for one macro expansion.
Not Copy, because Options::include_paths owns its list; the front
end clones it once per invocation.
Fields§
§standard: StandardWhich standard to accept.
dialect: DialectWhether the plain-spelled GNU extensions are switched on, and whether a
feature of a newer revision is accepted silently. See Dialect.
dollar_in_identifiers: boolAccept $ in identifiers, like GCC’s -fdollars-in-identifiers.
On by default, which is where GCC and Clang both keep it: WG14
DR027 lets an implementation put characters outside the basic source
character set into an identifier, GCC takes $ unconditionally, and
Clang takes it with a warning that only -pedantic-errors promotes.
A $ that reaches the generated Rust — which has no such spelling —
is written _dollar_ there, and the C name is what the symbol still
links by.
include_paths: Vec<PathBuf>Directories #include searches, after the ones the unit itself names
with #pragma cinrs include_path and before the bundled headers.
This is the programmatic way in; see crate::include for the whole
search order and for the CINRS_INCLUDE_PATH environment variable,
which comes last.
system_include: SystemWhether #include also searches the platform’s own directories, and
where in the order they go.
Off by default, which is what keeps a unit self-contained and
portable across target models. analyze replaces this with
what include::SYSTEM_ENV_VAR says when the caller left it at
include::System::Off, and the unit’s own
#pragma cinrs system_include replaces it again; see
include for the whole order and for the directories themselves.
target: TargetModelThe data model the generated code is compiled for.
Defaults to the host’s, which analyze replaces with the one
TARGET_ENV_VAR names and the unit’s own
#pragma cinrs target replaces again; see target for the order.
Whatever it ends up being, the expansion states it — the
const _: () = { assert!(…); }; block every unit opens with is built
from this model, so a unit expanded for one data model and compiled
for another fails to compile.
Setting it directly — Options::for_target is the tidy way — marks
Options::target_source Explicit, and the environment variable is
then left alone.
target_source: TargetSourceWhere Options::target came from, which the diagnostics name.
complex: boolWhether the complex types are available.
Defaults to COMPLEX_SUPPORTED, which is this crate’s complex
feature — the one the cinrs crate turns on to supply the cinrs-rt
runtime the generated code names. With it off, _Complex is a
diagnostic, __STDC_NO_COMPLEX__ is predefined, and nothing generated
needs more than core. The front end carries the support either way, so
a test may set this in either direction.
Implementations§
Source§impl Options
impl Options
Sourcepub fn new(standard: Standard) -> Self
pub fn new(standard: Standard) -> Self
Default options for standard, in the strict ISO dialect.
Sourcepub fn gnu(standard: Standard) -> Self
pub fn gnu(standard: Standard) -> Self
Default options for standard in the GNU dialect — what gnu99! and
friends use.
Sourcepub fn with_dialect(standard: Standard, dialect: Dialect) -> Self
pub fn with_dialect(standard: Standard, dialect: Dialect) -> Self
Default options for standard in dialect.
Sourcepub fn with_complex(self, complex: bool) -> Self
pub fn with_complex(self, complex: bool) -> Self
These options with the complex types switched on or off; see
Options::complex.
Sourcepub fn for_target(self, target: TargetModel) -> Self
pub fn for_target(self, target: TargetModel) -> Self
These options with target set, and marked as the caller’s choice so
that TARGET_ENV_VAR does not override it.
What a test that wants the ILP32 or LLP64 rules uses; a unit still
overrides it with #pragma cinrs target.
Sourcepub fn macro_name(&self) -> &'static str
pub fn macro_name(&self) -> &'static str
The macro that selects this entry point, as a diagnostic names it.
Sourcepub fn origin(&self) -> Origin
pub fn origin(&self) -> Origin
The origin a real expansion of this entry point has: the names the invocation may be written with, and the crate directory Cargo names.
This is what the procedural macros hand to expand_with, and the only
thing that lets capture find the invocation in the crate’s sources when
the host reports no positions. expand and analyze deliberately do
not use it; see Origin.
Sourcepub fn include_origin(&self) -> Origin
pub fn include_origin(&self) -> Origin
The same for the include_…! entry point of this standard and dialect.