Skip to content

Commit

Permalink
Output extern "C" function declarations and mark them 'extern'
Browse files Browse the repository at this point in the history
  • Loading branch information
eqrion committed Aug 12, 2017
1 parent ecc1cfc commit c545161
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 11 additions & 0 deletions compile-tests/extern.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[repr(C)]
struct Normal {
x: i32,
y: f32,
}

extern "C" {
fn foo() -> i32;

fn bar(a: Normal);
}
4 changes: 0 additions & 4 deletions src/bindgen/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ impl Bindings {
}

for function in &self.functions {
if function.extern_decl {
continue;
}

out.new_line_if_not_start();
function.write(&self.config, &mut out);
out.new_line();
Expand Down
6 changes: 6 additions & 0 deletions src/bindgen/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ impl Source for Function {
out.write(prefix);
out.write(" ");
}
if func.extern_decl {
out.write("extern ");
}
cdecl::write_func(out, &func, false);
if let Some(ref postfix) = postfix {
out.write(" ");
Expand All @@ -110,6 +113,9 @@ impl Source for Function {
out.write(prefix);
out.new_line();
}
if func.extern_decl {
out.write("extern ");
}
cdecl::write_func(out, &func, true);
if let Some(ref postfix) = postfix {
out.new_line();
Expand Down

0 comments on commit c545161

Please sign in to comment.