Skip to content

Commit 694441d

Browse files
committed
fix: generate wrapped static functions for C++
1 parent 32e4781 commit 694441d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

bindgen/codegen/mod.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -4677,7 +4677,7 @@ impl CodeGenerator for Function {
46774677

46784678
let should_wrap = is_internal &&
46794679
ctx.options().wrap_static_fns &&
4680-
link_name_attr.is_none();
4680+
(link_name_attr.is_none() || utils::is_cpp(ctx));
46814681

46824682
if should_wrap {
46834683
let name = canonical_name.clone() + ctx.wrap_static_fns_suffix();
@@ -5201,6 +5201,15 @@ pub(crate) mod utils {
52015201
use std::path::PathBuf;
52025202
use std::str::FromStr;
52035203

5204+
pub(super) fn is_cpp(context: &BindgenContext) -> bool {
5205+
args_are_cpp(&context.options().clang_args) ||
5206+
context
5207+
.options()
5208+
.input_headers
5209+
.iter()
5210+
.any(|h| file_is_cpp(h))
5211+
}
5212+
52045213
pub(super) fn serialize_items(
52055214
result: &CodegenResult,
52065215
context: &BindgenContext,
@@ -5220,14 +5229,8 @@ pub(crate) mod utils {
52205229
std::fs::create_dir_all(dir)?;
52215230
}
52225231

5223-
let is_cpp = args_are_cpp(&context.options().clang_args) ||
5224-
context
5225-
.options()
5226-
.input_headers
5227-
.iter()
5228-
.any(|h| file_is_cpp(h));
5229-
5230-
let source_path = path.with_extension(if is_cpp { "cpp" } else { "c" });
5232+
let source_path =
5233+
path.with_extension(if is_cpp(context) { "cpp" } else { "c" });
52315234

52325235
let mut code = Vec::new();
52335236

0 commit comments

Comments
 (0)