#[repr(u32)]
pub enum A {
Apple = 1,
Pear = 2,
Banana = 3,
}
#[repr(u32)]
pub enum B {
A = A::Apple as u32,
B = A::Pear as u32,
C = A::Banana as u32,
}
and the cbindgen.toml config
language = "C"
cpp_compat = false
[export]
include = ["A", "B"]
item_types = ["enums"]
[enum]
rename_variants = "QualifiedScreamingSnakeCase"
The command cbindgen -c cbindgen.toml foo.rs generates:
Given the Rust file foo.rs:
and the cbindgen.toml config
The command
cbindgen -c cbindgen.toml foo.rs
generates:Note that
B_A
is initialized fromA_Apple
rather thanA_APPLE
, ignoring therename_variants = "QualifiedScreamingSnakeCase"
config option.