include_c99!() { /* proc-macro */ }Expand description
Compiles the C99 file at path — one translation unit, exactly as if its
text had been written inside c99!.
cinrs::include_c99!("vendor/parser.c");The file is read at expansion time and translated with the same front end:
every C construct is accepted (the file is text, so the lexemes Rust’s own
lexer refuses are no trouble), #pragma cinrs … inside it configures the
unit, #include "…" in it searches the file’s own directory first, and the
expansion is a module plus a glob re-export like any other invocation’s.
__FILE__ and __LINE__ name the .c file and its own lines.
A relative path is resolved against the directory of the .rs file the
macro is written in — the same rule #include "…" follows — and an
absolute one is used as it stands. The file is named with include_str! in
the expansion, so editing it rebuilds the crate.
Diagnostics land on the invocation. There is no C in the .rs file for
a caret to point at, so a message of this crate’s carries the position
inside the file — vendor/parser.c:12:5: unknown type name 'foo' — and an
error rustc raises about the generated code is reported at the macro call.
Neither cargo nor an IDE will jump into the .c file; the position is in
the text of the message.
There is one of these per entry point: include_c89!, include_c90!,
include_c11!, include_c17!, include_c23! and the five include_gnu…!
forms.