Skip to content

Commit fde49a8

Browse files
committed
Make sure macro wrapper functions have the correct link name
1 parent 9733606 commit fde49a8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen/codegen/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4114,7 +4114,8 @@ impl CodeGenerator for Function {
41144114
debug!("<Function as CodeGenerator>::codegen: item = {:?}", item);
41154115
debug_assert!(item.is_enabled_for_codegen(ctx));
41164116

4117-
if self.kind() == FunctionKind::Macro {
4117+
let is_function_macro = self.kind() == FunctionKind::Macro;
4118+
if is_function_macro {
41184119
result
41194120
.items_to_serialize
41204121
.push(SerializableItem::MacroFunction(item.id()));
@@ -4264,6 +4265,9 @@ impl CodeGenerator for Function {
42644265
if should_wrap {
42654266
let name = canonical_name.clone() + ctx.wrap_static_fns_suffix();
42664267
attributes.push(attributes::link_name::<true>(&name));
4268+
} else if is_function_macro && !has_link_name_attr {
4269+
let name = canonical_name.clone() + "__macro";
4270+
attributes.push(attributes::link_name::<true>(&name));
42674271
}
42684272

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

0 commit comments

Comments
 (0)