Crates.io | cpreprocess |
lib.rs | cpreprocess |
version | 1.0.2 |
source | src |
created_at | 2022-03-02 22:32:40.834263 |
updated_at | 2022-04-07 17:45:06.471428 |
description | Procedural macro that runs a C preprocessor on the input |
homepage | |
repository | https://github.com/WilliamVenner/cpreprocess |
max_upload_size | |
id | 542575 |
size | 9,347 |
Stupid and cursed Rust procedural macro that runs a C preprocessor on the input
[dependencies]
cpreprocess = "*"
fn main() {
cpreprocess::cpreprocess!(r#"
#define MACRO(NAME) fn print_ ## NAME () { println!("hello world"); }
MACRO(hello_world)
print_hello_world()
"#)
}
If you're using the Rust nightly compiler, you can use the macro without a string literal. Just enable the nightly
Cargo feature for this crate.
I think this is largely experimental, as it relies on a non-100% accurate method of extracting the contents of the macro.
fn main() {
cpreprocess::cpreprocess! {
#define MACRO(NAME) fn print_ ## NAME () { println!("hello world"); }
MACRO(hello_world)
print_hello_world()
}
}