Skip to content

Commit aa05fdf

Browse files
committed
options: Ensure to pass the clang header last to clang.
1 parent 09c66d1 commit aa05fdf

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

libbindgen/src/lib.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ impl Builder {
168168
/// Set the input C/C++ header.
169169
pub fn header<T: Into<String>>(mut self, header: T) -> Builder {
170170
let header = header.into();
171-
self.options.input_header = Some(header.clone());
172-
self.clang_arg(header)
171+
self.options.input_header = Some(header);
172+
self
173173
}
174174

175175
/// Generate a C/C++ file that includes the header and has dummy uses of
@@ -504,11 +504,15 @@ impl<'ctx> Bindings<'ctx> {
504504
///
505505
/// Deprecated - use a `Builder` instead
506506
#[deprecated]
507-
pub fn generate(options: BindgenOptions,
507+
pub fn generate(mut options: BindgenOptions,
508508
span: Option<Span>)
509509
-> Result<Bindings<'ctx>, ()> {
510510
let span = span.unwrap_or(DUMMY_SP);
511511

512+
if let Some(h) = options.input_header.as_ref() {
513+
options.clang_args.push(h.clone())
514+
}
515+
512516
let mut context = BindgenContext::new(options);
513517
try!(parse(&mut context));
514518

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
#[repr(C)]
8+
#[derive(Debug, Copy, Clone)]
9+
pub struct Foo<T> {
10+
pub bar: ::std::os::raw::c_int,
11+
pub _phantom_0: ::std::marker::PhantomData<T>,
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// bindgen-flags: -- -x c++ --std=c++11
2+
3+
template<typename T>
4+
struct Foo {
5+
int bar;
6+
};

0 commit comments

Comments
 (0)