Skip to content

Commit

Permalink
Make sure macro wrapper functions have the correct link name
Browse files Browse the repository at this point in the history
  • Loading branch information
Abestanis committed Jul 11, 2023
1 parent a00552b commit 3e82041
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions bindgen-tests/tests/expectations/tests/function_macros.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4100,7 +4100,8 @@ impl CodeGenerator for Function {
debug!("<Function as CodeGenerator>::codegen: item = {:?}", item);
debug_assert!(item.is_enabled_for_codegen(ctx));

if self.kind() == FunctionKind::Macro {
let is_function_macro = self.kind() == FunctionKind::Macro;
if is_function_macro {
result
.items_to_serialize
.push(SerializableItem::MacroFunction(item.id()));
Expand Down Expand Up @@ -4250,6 +4251,9 @@ impl CodeGenerator for Function {
if should_wrap {
let name = canonical_name.clone() + ctx.wrap_static_fns_suffix();
attributes.push(attributes::link_name::<true>(&name));
} else if is_function_macro && !has_link_name_attr {
let name = canonical_name.clone() + "__macro";
attributes.push(attributes::link_name::<true>(&name));
}

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

0 comments on commit 3e82041

Please sign in to comment.