Skip to content

Commit b743ab0

Browse files
committed
codegen: Don't implement variadic methods.
Fixes #402
1 parent f103d8a commit b743ab0

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

libbindgen/src/codegen/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,12 @@ impl MethodCodegen for Method {
12951295
_ => panic!("How in the world?"),
12961296
};
12971297

1298+
// Do not generate variadic methods, since rust does not allow
1299+
// implementing them, and we don't do a good job at it anyway.
1300+
if signature.is_variadic() {
1301+
return;
1302+
}
1303+
12981304
let count = {
12991305
let mut count = method_names.entry(name.clone())
13001306
.or_insert(0);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
extern "C" {
8+
#[link_name = "_Z3fooPKcz"]
9+
pub fn foo(fmt: *const ::std::os::raw::c_char, ...);
10+
}
11+
#[repr(C)]
12+
#[derive(Debug, Copy)]
13+
pub struct Bar {
14+
pub _address: u8,
15+
}
16+
#[test]
17+
fn bindgen_test_layout_Bar() {
18+
assert_eq!(::std::mem::size_of::<Bar>() , 1usize);
19+
assert_eq!(::std::mem::align_of::<Bar>() , 1usize);
20+
}
21+
extern "C" {
22+
#[link_name = "_ZN3Bar3fooEPKcz"]
23+
pub fn Bar_foo(this: *mut Bar, fmt: *const ::std::os::raw::c_char, ...);
24+
}
25+
impl Clone for Bar {
26+
fn clone(&self) -> Self { *self }
27+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
void foo(const char* fmt, ...);
3+
4+
struct Bar {
5+
void foo(const char* fmt, ...);
6+
};

0 commit comments

Comments
 (0)