cbindgen
cbindgen copied to clipboard
Rename items with a rule
Everything else can have a rename rule. Why not items too!
Example below. Nice and neat, no #![allow(non_camel_case_types)] required.
#[repr(c)]
struct StructDef {
x: i32,
y: f32,
}
type TypeAlias = StructDef;
// doesn't apply to functions, obviously
// also this PR fixes misleading example in docs for [export.rename] which purported to apply to a function name
#[no_mangle]
extern "C" fn capi_write(obj: *mut StructDef) {}
[export]
prefix = "capi_"
rename_items = "snake_case"
typedef struct {
int32_t x;
float y;
} capi_struct_def;
typedef capi_struct_def capi_type_alias;
void capi_write(capi_struct_def *def);
I realised this is a dupe of #419. This one has tests though.
Hi. Any change of getting this merged/release soon?