Skip to content

Commit 3e82041

Browse files
committed
Make sure macro wrapper functions have the correct link name
1 parent a00552b commit 3e82041

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bindgen-tests/tests/expectations/tests/function_macros.rs

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen/codegen/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -4100,7 +4100,8 @@ impl CodeGenerator for Function {
41004100
debug!("<Function as CodeGenerator>::codegen: item = {:?}", item);
41014101
debug_assert!(item.is_enabled_for_codegen(ctx));
41024102

4103-
if self.kind() == FunctionKind::Macro {
4103+
let is_function_macro = self.kind() == FunctionKind::Macro;
4104+
if is_function_macro {
41044105
result
41054106
.items_to_serialize
41064107
.push(SerializableItem::MacroFunction(item.id()));
@@ -4250,6 +4251,9 @@ impl CodeGenerator for Function {
42504251
if should_wrap {
42514252
let name = canonical_name.clone() + ctx.wrap_static_fns_suffix();
42524253
attributes.push(attributes::link_name::<true>(&name));
4254+
} else if is_function_macro && !has_link_name_attr {
4255+
let name = canonical_name.clone() + "__macro";
4256+
attributes.push(attributes::link_name::<true>(&name));
42534257
}
42544258

42554259
let wrap_as_variadic = if should_wrap && !signature.is_variadic() {

0 commit comments

Comments
 (0)