GithubHelp home page GithubHelp logo

rust-lang / rust-bindgen Goto Github PK

View Code? Open in Web Editor NEW
4.1K 54.0 667.0 17.17 MB

Automatically generates Rust FFI bindings to C (and some C++) libraries.

Home Page: https://rust-lang.github.io/rust-bindgen/

License: BSD 3-Clause "New" or "Revised" License

Rust 97.80% C 0.13% Shell 0.52% Batchfile 0.13% Python 1.41% Makefile 0.01%
ffi bindings codegen

rust-bindgen's Introduction

crates.io docs.rs

bindgen

bindgen automatically generates Rust FFI bindings to C (and some C++) libraries.

For example, given the C header doggo.h:

typedef struct Doggo {
    int many;
    char wow;
} Doggo;

void eleven_out_of_ten_majestic_af(Doggo* pupper);

bindgen produces Rust FFI code allowing you to call into the doggo library's functions and use its types:

/* automatically generated by rust-bindgen 0.99.9 */

#[repr(C)]
pub struct Doggo {
    pub many: ::std::os::raw::c_int,
    pub wow: ::std::os::raw::c_char,
}

extern "C" {
    pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
}

Users Guide

๐Ÿ“š Read the bindgen users guide here! ๐Ÿ“š

MSRV

The bindgen minimum supported Rust version is 1.60.0.

The bindgen-cli minimum supported Rust version is 1.64.0.

No MSRV bump policy has been established yet, so MSRV may increase in any release.

The MSRV is the minimum Rust version that can be used to compile each crate. However, bindgen and bindgen-cli can generate bindings that are compatible with Rust versions below the current MSRV.

Most of the time, the bindgen-cli crate will have a more recent MSRV than bindgen as crates such as clap require it.

API Reference

API reference documentation is on docs.rs

Environment Variables

In addition to the library API and executable command-line API, bindgen can be controlled through environment variables.

End-users should set these environment variables to modify bindgen's behavior without modifying the source code of direct consumers of bindgen.

  • BINDGEN_EXTRA_CLANG_ARGS: extra arguments to pass to clang
    • Arguments are whitespace-separated
    • Use shell-style quoting to pass through whitespace
    • Examples:
      • Specify alternate sysroot: --sysroot=/path/to/sysroot
      • Add include search path with spaces: -I"/path/with spaces"
  • BINDGEN_EXTRA_CLANG_ARGS_<TARGET>: similar to BINDGEN_EXTRA_CLANG_ARGS, but used to set per-target arguments to pass to clang. Useful to set system include directories in a target-specific way in cross-compilation environments with multiple targets. Has precedence over BINDGEN_EXTRA_CLANG_ARGS.

Additionally, bindgen uses libclang to parse C and C++ header files. To modify how bindgen searches for libclang, see the clang-sys documentation. For more details on how bindgen uses libclang, see the bindgen users guide.

Releases

We don't follow a specific release calendar, but if you need a release please file an issue requesting that (ping @emilio for increased effectiveness).

Contributing

See CONTRIBUTING.md for hacking on bindgen!

rust-bindgen's People

Contributors

bkchr avatar blei avatar crabtw avatar drchat avatar ebarnard avatar eijebong avatar elichai avatar emilio avatar fitzgen avatar flier avatar jdub avatar jeanphilipped avatar jsgf avatar justsmth avatar kornelski avatar kulp avatar lopopolo avatar manishearth avatar mikuroxina avatar nox avatar pepyakin avatar photoszzt avatar pvdrz avatar scoopr avatar simlay avatar tamird avatar tmfink avatar tshepang avatar upsuper avatar yamakaky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-bindgen's Issues

Don't force users to manually install llvm/clang

The bindgen installation + use workflow I'd like to have would be:

$ cargo install servo-bindgen

And that's it. No more wrangling [DY]LD_LIBRARY_PATH either.

Right now, we are very far from that.

I think we need two things to get there:

  1. Vendor llvm3.9 in tree and build it in build.rs. This seems easy enough.
  2. Statically link llvm/clang into bindgen. Less sure how easy this will be.

@emilio how feasible do you think this is?

Generate type ids lazily

This will prevent small changes from creating large diffs in the bindings. Emilio says it will also improve the tests.

Deduplicate names of overloaded virtual methods

Test case:

class Stream {
    public:
    virtual void write(char* string);
    virtual void write(void* buffer, unsigned int size);
};

Code generated by bindgen 1e26a8a:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_Stream {
    pub _vftable: *const _vftable_Struct_Stream,
}
#[repr(C)]
pub struct _vftable_Struct_Stream {
    pub write: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void,
                                    string: *mut ::std::os::raw::c_char),
    pub write: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void,
                                    buffer: *mut ::std::os::raw::c_void,
                                    size: ::std::os::raw::c_uint),
}
impl ::std::clone::Clone for Struct_Stream {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_Stream() {
    assert_eq!(::std::mem::size_of::<Struct_Stream>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_Stream>() , 8usize);
}

Struct fields with the same name are an error in Rust. Similar code fails with:

    --> src/bindings.rs:1987:5
     |
1985 |     pub write: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void, b: u8)
     |     - `write` first declared here
1986 |                    -> usize,
1987 |     pub write: unsafe extern "C" fn(this: *mut ::std::os::raw::c_void,
     |     ^ field already declared

The field names should probably be deduplicated by appending an integer, like for names of non-virtual methods.

CC @emilio @nox

merge into upstream!

Did you consider to merge your modifications into my repo? We both added a lot of features, it would be great if we could join forces.

Methods cause infinite recursion

Right now we don't generate methods, but if these are turned on, the PartialEq impl on Type recurses infinitely -- CompInfo contains methods, which are FuncSigs, which may contain the type itself.

We should use pointer equality here.

Find a better way of representing complex numbers types in Rust

I plan to land parsing and code generation support for complex types. My initial plan is landing it as a constant array of items, but that doesn't mean we can't do better.

We'd need to add a new TypeKind::Complex(ItemId), then use that to represent complex types. Then, at code generation, we can do something like what we do with unions, and conditionally prepend a prelude that might look like:

#[repr(C)]
#[derive(ABunchOfThings)]
struct __BindgenComplex<T> {
    real: T,
    imaginary: T,
};

With arithmetic operations on top of it.

C++ features we can't handle right now.

This is a list of things we can't handle correctly in bindgen, and we're not expected to be able to in a while.

Partial template specialization

We can't get the specialized types from a construct like this via libclang, rather unfortunately. We do hackily search through the ast to get the non-specialized ones though.

template<typename T, typename U>
class Foo { };

template<typename T>
class Bar {
  Foo<T, int> mFoo;
};

In the above example the ast for Bar is the following:

(ClassTemplate Bar Invalid
    (TemplateTypeParameter T Unexposed
    )
    (FieldDecl mFoo Unexposed
        (TemplateRef Foo Invalid
        )
        (TypeRef T Unexposed
        )
    )
)

And type template parameter related functions in bindgen don't give us any information.

Template unions with template parameters inside.

We can't handle this because the size of the union depends on size_of::<T>, and that's not const fn (and we can't use const fn in stable anyway). We can try to compute it and be correct if T is not the largest type in the union.

template<typename T>
union Bar {
  T mFoo;
  int mBar;
};

Using clang-sys for header paths breaks any non-default-target builds

This breaks msvc (or really any non-default-target bindings generation):

When llvm/clang is built for the gnu target by default (needed for msvc bindings generation, because it's easier to use those default include paths and let the msvc target get them from $INCLUDE), clang behaves properly:

$ vladimir@glacier[5307]$ clang -E -x c++ - -v
Target: x86_64-w64-windows-gnu
[...]
#include "..." search starts here:
#include <...> search starts here:
 W:\msys64\mingw64\include\c++\6.1.0
 W:\msys64\mingw64\include\c++\6.1.0\x86_64-w64-mingw32
 W:\msys64\mingw64\include\c++\6.1.0\backward
 C:\proj\llvm\build-mingw64\bin\..\lib\clang\3.9.0\include
 W:\msys64\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include
 W:\msys64\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include-fixed
 W:\msys64\mingw64\x86_64-w64-mingw32\include
 W:\msys64\mingw64\include
End of search list.
$ vladimir@glacier[5307]$ clang --target=x86_64-pc-win32 -E -x c++ - -v
Target: x86_64-pc-windows-msvc
[...]
#include "..." search starts here:
#include <...> search starts here:
 C:\proj\llvm\build-mingw64\bin\..\lib\clang\3.9.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt
End of search list.

But when rust-bindgen is passed --target=x86_64-pc-win32, it gets:

$ ./etc/bindings.sh msvc14
...
Target: x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 ../target/debug/build/mozjs_sys-4ab490f4d99d7124/out/dist/include
 W:\msys64\mingw64\include\c++\6.1.0
 W:\msys64\mingw64\include\c++\6.1.0\x86_64-w64-mingw32
 W:\msys64\mingw64\include\c++\6.1.0\backward
 C:\proj\llvm\build-mingw64\bin\..\lib\clang\3.9.0\include
 W:\msys64\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include
 W:\msys64\mingw64\lib\gcc\x86_64-w64-mingw32\6.1.0\include-fixed
 W:\msys64\mingw64\x86_64-w64-mingw32\include
 W:\msys64\mingw64\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10586.0\winrt
End of search list.

which then totally breaks the generation.

I'm going to hack around this by skipping the clang-sys isystem stuff (why is it needed?) if --target is specified.

Meta: ease contributing to bindgen

Ramping up on bindgen as a newcomer is harder than it should be (eg #51 (comment)) so we should make it easier. This will serve as a meta bug for such issues.

Will add more here as file more issues.

  • Make cargo test work: #51
  • Add a CONTRIBUTING.md file w/ an overview of bindgen's architecture: #93
  • Add #![deny(missing_docs)]: #94
  • Don't run tests expected to fail if --features llvm_stable is missing: #97

Possible perf improvements.

Just a few I'm thinking about off the top of my head, just in case someone wants to get to them.

  • Reuse builtin types indexed by constness.
  • Use fnv.
  • Parallelize codegen? (Should be easy-ish using rayon).

Deduplicate statics

Test case:

extern int foo;
extern int foo;

In the real case where I hit this, the two declarations are in separate files. Still, I believe that multiple identical declarations are legal in C++.

Code generated by bindgen with commit 1e26a8a:

extern "C" {
    pub static mut foo: ::std::os::raw::c_int;
    pub static mut foo: ::std::os::raw::c_int;
}

Building code like this makes rustc emit an error:

error[E0428]: a value named `systick_millis_count` has already been defined in this module
    --> src/bindings.rs:3231:5
     |
3207 |     pub static mut systick_millis_count: ::std::os::raw::c_uint;
     |     ------------------------------------------------------------ previous definition of `systick_millis_count` here
...
3231 |     pub static mut systick_millis_count: ::std::os::raw::c_uint;
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ already defined

Remove TypeResolver

I added it while writing the refactoring, but now it's just a dumb alias that brings nothing to the game.

We could be smarter about implementing Copy/Clone

Testcase:

template<typename T>
struct Foo {
    char bar[50];
};

vs.

struct Foo {
    char bar[50];
};

We're conservative here, but we could be smarter if we know the struct has no template parameters, since all the arrays (even the big ones) implement magically Copy, so we can do:

impl Clone for MyStruct { fn clone(&self) -> Self { *self } }

But this wouldn't work for templated structs, where we derive it.

stop blacklisting `Wrapper` and illegal code is generated

Input adapted from double_replaces.hpp by removing the --blacklist-type Wrapper flag:

// bindgen-flags: -- --std=c++11

namespace JS {

namespace detail {

template<typename T>
struct Wrapper {
    struct Wrapped {
        T t;
    };
    using Type = Wrapped;
};

template <typename T>
using MaybeWrapped = typename Wrapper<T>::Type;

}

template<typename T>
class Rooted {
    detail::MaybeWrapped<T> ptr;
};

}

/**
 * <div rustbindgen replaces="MaybeWrapped"></div>
 */
template <typename T>
using replacement_MaybeWrapped = T;

Generated type definition for Wrapper_Wrapped is missing the template parameter:

error[E0412]: type name `T` is undefined or not in scope
  --> tests/expectations/replaces_double_from_outside.rs:18:41
   |
18 | pub type Wrapper_Type = Wrapper_Wrapped<T>;
   |                                         ^ undefined or not in scope
   |
   = help: no candidates by the name of `T` found in your project; maybe you misspelled the name or forgot to import an external crate?

error: aborting due to previous error

Point to the `--whitelist` flags or reporting a bug when we error on binding generation.

Running bindgen on the headers of any nontrivial API tends to generate bindings for most of the C/C++ standard library, which is at best undesirable, often doesnโ€™t compile, and sometimes makes even the binding generation fail. The work-around is to use --match to only generate bindings for declarations in relevant header files. (Fortunately, matching can be on a directory name so that there is no need to list each single file individually.)

So it seems to me that --match is necessary in practice. Running without it should probably print a message explaining all this, rather than leave the user wondering why they have dozens of compiler errors.

Failing test case w/ replaces and using in namespaces

cc @emilio

Input:

// bindgen-flags: -- -x c++ -std=c++14

namespace JS {
    namespace detail {
        template <typename T>
        struct Wrapped {
            T t;
        };
    }

    template <typename T>
    struct Rooted {
        detail::Wrapped<T> ptr;
    };
}

namespace JS {
    namespace detail {
        /**
         * <div rustbindgen replaces="Wrapped" />
         */
        template <typename T>
        using Wrapped_simple = T;
    }
}

Output:

/* automatically generated by rust-bindgen */


#![allow(non_snake_case)]


#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Rooted<T> {
    pub ptr: Wrapped<T>,
}

I'd expect there to be a pub type Wrapped<T> = T; in the output.

Type renaming is broken

Test case:

class Thing {
    public:
    bool compare(Thing &other);
};

Code generated by bindgen 1e26a8a:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_Thing;
impl ::std::clone::Clone for Struct_Thing {
    fn clone(&self) -> Self { *self }
}
extern "C" {
    fn _ZN5Thing7compareERS_(this: *mut Thing, other: *mut Struct_Thing)
     -> bool;
}
impl Struct_Thing {
    #[inline]
    pub unsafe fn compare(&mut self, other: *mut Struct_Thing) -> bool {
        _ZN5Thing7compareERS_(&mut *self, other)
    }
}

โ€ฆ which fails to build with:

error[E0412]: type name `Thing` is undefined or not in scope
  --> <anon>:10:41
   |
10 |     fn _ZN5Thing7compareERS_(this: *mut Thing, other: *mut Struct_Thing)
   |                                         ^^^^^ undefined or not in scope
   |
   = help: no candidates by the name of `Thing` found in your project; maybe you misspelled the name or forgot to import an external crate?

Using --no-type-renaming works around the issue.

By the way, why is type renaming the default?

MacPorts Clang 3.9 Instructions

I use MacPorts on OS X, and was able to build bindgen. You might want to consider adding instructions to the readme:

  1. To install clang:
    port install clang-3.9
  2. And to build rust-bindgen:
LIBCLANG_PATH=/opt/local/libexec/llvm-3.9/lib \
LD_LIBRARY_PATH=/opt/local/libexec/llvm-3.9/lib \
cargo build

Should be able to generate spidermonkey bindings without downstream patches

Right now, servo/mozjs has a bunch of downstream patches that simplify and dumb down spidermonkey headers and even completely hide various types.

We should get to the point where we don't need these downstream patches, and can run bindgen in CI for mozilla-central. That doesn't necessarily mean that we have to generate bindings for all of C++, but maybe have some configuration of things to ignore rather than manually ifdef away chunks of code.

Blocks https://bugzilla.mozilla.org/show_bug.cgi?id=1277343

Replacing template alias that does not use its template parameter with one that does is broken

// bindgen-flags: -- --std=c++14

namespace JS {
namespace detail {

// Notice how this doesn't use T.
template <typename T>
using MaybeWrapped = int;

}

template <typename T>
class Rooted {
    detail::MaybeWrapped<T> ptr;
};

}

/// But the replacement type does use T!
///
/// <div rustbindgen replaces="MaybeWrapped" />
template <typename T>
using replaces_MaybeWrapped = T;

Oh man this took a while to track down. I'm hitting this in the SM bindings because we don't understand mozilla::Conditional and therefore don't understand that it is using T and we shouldn't filter the type parameter out for being unused, but we aren't smart enough to understand that.

I "fixed" this with this diff:

             TypeKind::Alias(_, inner) => {
                 let parent_args = ctx.resolve_item(self.parent_id())
                    .applicable_template_args(ctx);
                 let inner = ctx.resolve_type(inner);
                 // Avoid unused type parameters, sigh.
                 parent_args.iter().cloned().filter(|arg| {
-                    let arg = ctx.resolve_type(*arg);
-                    arg.is_named() && inner.signature_contains_named_type(ctx, arg)
+                    // let arg = ctx.resolve_type(*arg);
+                    // arg.is_named() && inner.signature_contains_named_type(ctx, arg)
+
+                    true
                 }).collect()
             }

however that breaks perfectly reasonable things like tests/headers/template_typedefs.h.

Clearly we need to be smarter about type parameters, but I'm not 100% sure how to do that yet, and I'm still fumbling around this code base.

js/public/Utilities.h's `UniqueChars` typedef not being picked up

Not 100% sure if this is a bindgen bug or a rust-mozjs/etc/bindings.sh bug, but @emilio asked me to file.

The typedef here isn't being picked up by bindgen: http://searchfox.org/mozilla-central/rev/b38dbd1378cea4ae83bbc8a834cdccd02bbc5347/js/public/Utility.h#587

Which results in this error in the generated bindings code:

bash-4.3$ LIBCLANG_PATH=~/src/llvm/obj/lib LD_LIBRARY_PATH=~/src/llvm/obj/lib cargo test --features debugmozjs
   Compiling js v0.1.3 (file:///home/fitzgen/src/rust-mozjs)
src/jsapi_linux_64_debug.rs:8784:55: 8784:66 error: type name `UniqueChars` is undefined or not in scope [E0412]
src/jsapi_linux_64_debug.rs:8784     pub fn JS_GetDefaultLocale(cx: *mut JSContext) -> UniqueChars;

In the meantime, I'm going to hide the JS_GetDefaultLocale function, because it isn't used in rust-mozjs...

Detect forward declarations and generate opaque enums for them.

We should be able to detect forward declarations in bindgen, and generate opaque enums if appropriate, instead of structs with an address byte.

We should check clang_getCursorDefinition() and clang_isCursorDefinition to check whether what we're scanning, mark the generated type accordingly, and do the proper codegen steps.

`cargo test` on master fails hard locally

After a cargo clean:

$ cargo test
   Compiling bitflags v0.7.0
   Compiling rustc-serialize v0.3.19
   Compiling glob v0.2.11
   Compiling unicode-xid v0.0.3
   Compiling winapi-build v0.1.1
   Compiling bitflags v0.5.0
   Compiling winapi v0.2.8
   Compiling libc v0.2.14
   Compiling log v0.3.6
   Compiling kernel32-sys v0.2.2
   Compiling term v0.4.4
   Compiling clang-sys v0.8.1
   Compiling syntex_pos v0.38.0
   Compiling syntex_errors v0.38.0
   Compiling syntex_syntax v0.38.0
   Compiling aster v0.21.1
   Compiling quasi v0.15.0
   Compiling syntex v0.38.0
   Compiling quasi_codegen v0.15.0
   Compiling bindgen v0.16.0 (file:///Users/fitzgen/src/rust-bindgen)
tests/test_cxx.rs:1:5: 1:12 warning: unused import, #[warn(unused_imports)] on by default
tests/test_cxx.rs:1 use bindgen;
                        ^~~~~~~
     Running target/debug/bindgen-be57e02bfe45306e

running 1 test
test builder_state ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

     Running target/debug/bindgen-0e203d5c160e4a07

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

     Running target/debug/tests-98ced5f25666801d

running 33 tests
error: error reading 'tests/headers/builtin_va_list.h'
test test_builtins::test_builtin_va_list ... FAILED
test test_decl::ptr_to_array ... ok
test test_enum::with_duplicate_enum_value ... FAILED
test test_enum::with_simple_enum ... FAILED
test test_enum::with_overflowed_enum_value ... FAILED
test test_enum::with_packed_enums ... FAILED
test test_enum::with_explicitly_typed_cxx_enum ... FAILED
test test_cxx::test_cxx_template ... FAILED
test test_cxx::test_cxx_class ... FAILED
test test_func::func_proto ... ok
test test_func::with_array_arg ... ok
test test_func::func_ptr ... ok
test test_extern::extern_c_in_hpp ... ok
test test_func::func_ptr_in_struct ... FAILED
test test_func::with_func_ptr_arg ... ok
test test_struct::containing_fwd_decl_struct ... FAILED
test test_struct::packed_struct ... FAILED
test test_struct::with_anon_struct_pointer ... FAILED
test test_struct::with_anon_struct ... FAILED
test test_struct::with_anon_struct_array ... FAILED
test test_struct::with_anon_unnamed_struct ... FAILED
test test_struct::with_anon_union ... FAILED
test test_struct::with_anon_unnamed_union ... FAILED
test test_struct::with_fwd_decl_struct ... FAILED
test test_union::with_anon_struct ... FAILED
test test_struct::with_bitfields ... FAILED
test test_union::with_anon_struct_bitfield ... FAILED
test test_union::with_anon_union ... FAILED
test test_union::with_anon_unnamed_struct ... FAILED
test test_struct::with_nesting ... FAILED
test test_union::with_anon_unnamed_union ... FAILED
test test_union::with_derive_debug ... FAILED
test test_union::with_nesting ... FAILED

failures:

---- test_builtins::test_builtin_va_list stdout ----
    thread 'test_builtins::test_builtin_va_list' panicked at 'called `Result::unwrap()` on an `Err` value: ()', ../src/libcore/result.rs:788
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- test_enum::with_duplicate_enum_value stdout ----
    Generated bindings for headers/enum_dupe.h do not match the reference bindings.

Generated:

pub const Dupe: Enum_Foo = Enum_Foo::Bar;
#[repr(u32)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Foo { Bar = 1, }

Reference:

pub const Dupe: Enum_Foo = Enum_Foo::Bar;
#[repr(u32)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Foo { Bar = 1, }
thread 'test_enum::with_duplicate_enum_value' panicked at 'explicit panic', tests/support.rs:66

---- test_enum::with_simple_enum stdout ----
    Generated bindings for headers/enum.h do not match the reference bindings.

Generated:

#[repr(u32)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i32)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }

Reference:

#[repr(u32)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i32)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }
thread 'test_enum::with_simple_enum' panicked at 'explicit panic', tests/support.rs:66

---- test_enum::with_overflowed_enum_value stdout ----
    Generated bindings for headers/overflowed_enum.hpp do not match the reference bindings.

Generated:

#[repr(u32)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Foo {
    BAP_ARM = 9698489,
    BAP_X86 = 11960045,
    BAP_X86_64 = 3128633167,
}
#[repr(u16)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Bar { One = 1, Big = 2, }

Reference:

#[repr(u32)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Foo {
    BAP_ARM = 9698489,
    BAP_X86 = 11960045,
    BAP_X86_64 = 3128633167,
}
#[repr(u16)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Bar { One = 1, Big = 2, }
thread 'test_enum::with_overflowed_enum_value' panicked at 'explicit panic', tests/support.rs:66

---- test_enum::with_packed_enums stdout ----
    Generated bindings for headers/enum_packed.h do not match the reference bindings.

Generated:

#[repr(u8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }
#[repr(u16)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Bigger { Much = 255, Larger = 256, }

Reference:

#[repr(u8)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i8)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }
#[repr(u16)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Bigger { Much = 255, Larger = 256, }
thread 'test_enum::with_packed_enums' panicked at 'explicit panic', tests/support.rs:66

---- test_enum::with_explicitly_typed_cxx_enum stdout ----
    Generated bindings for headers/enum_explicit_type.hpp do not match the reference bindings.

Generated:

#[repr(u8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i8)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }
#[repr(u16)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_Bigger { Much = 255, Larger = 256, }
#[repr(i64)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_MuchLong { MuchLow = -4294967296, }
#[repr(u64)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_MuchLongLong { MuchHigh = 4294967296, }

Reference:

#[repr(u8)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Foo { Bar = 0, Qux = 1, }
#[repr(i8)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Neg { MinusOne = -1, One = 1, }
#[repr(u16)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_Bigger { Much = 255, Larger = 256, }
#[repr(i64)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_MuchLong { MuchLow = -4294967296, }
#[repr(u64)]
#[derive(Copy, Clone, Debug)]
pub enum Enum_MuchLongLong { MuchHigh = 4294967296, }
thread 'test_enum::with_explicitly_typed_cxx_enum' panicked at 'explicit panic', tests/support.rs:66

---- test_cxx::test_cxx_template stdout ----
    *** NestedReplaced: found previous translation
*** ReplacedWithoutDestructor: found previous translation
Generated bindings for headers/template.hpp do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug)]
pub struct Foo<T, U> {
    pub m_member: T,
    pub m_member_ptr: *mut T,
    pub m_member_arr: [T; 1usize],
    pub _phantom0: ::std::marker::PhantomData<U>,
}
#[repr(C)]
#[derive(Debug)]
pub struct D<T> {
    pub m_foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>,
    pub _phantom0: ::std::marker::PhantomData<T>,
}
#[repr(C)]
#[derive(Debug)]
pub struct D_U<T, Z> {
    pub m_nested_foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>,
    pub m_baz: Z,
    pub _phantom0: ::std::marker::PhantomData<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Rooted<T> {
    pub prev: *mut T,
    pub next: *mut Rooted<*mut ::std::os::raw::c_void>,
    pub ptr: T,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct RootedContainer {
    pub root: Rooted<*mut ::std::os::raw::c_void>,
}
impl ::std::clone::Clone for RootedContainer {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_RootedContainer() {
    assert_eq!(::std::mem::size_of::<RootedContainer>() , 24usize);
    assert_eq!(::std::mem::align_of::<RootedContainer>() , 8usize);
}
pub type WithDtorIntFwd = WithDtor<::std::os::raw::c_int>;
#[repr(C)]
#[derive(Debug)]
pub struct WithDtor<T> {
    pub member: T,
}
#[repr(C)]
#[derive(Debug)]
pub struct PODButContainsDtor {
    pub member: WithDtorIntFwd,
}
#[test]
fn bindgen_test_layout_PODButContainsDtor() {
    assert_eq!(::std::mem::size_of::<PODButContainsDtor>() , 4usize);
    assert_eq!(::std::mem::align_of::<PODButContainsDtor>() , 4usize);
}
#[repr(C)]
pub struct Opaque;
#[repr(C)]
pub struct POD {
    pub opaque_member: u32,
}
#[test]
fn bindgen_test_layout_POD() {
    assert_eq!(::std::mem::size_of::<POD>() , 4usize);
    assert_eq!(::std::mem::align_of::<POD>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NestedBase<T, U> {
    pub buff: *mut T,
    pub _phantom0: ::std::marker::PhantomData<U>,
}
/**
 * <div rustbindgen replaces="NestedReplaced"></div>
 */
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NestedReplaced<T> {
    pub buff: *mut T,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct NestedContainer<T> {
    pub c: T,
    pub nested: NestedReplaced<T>,
    pub inc: Incomplete<T>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Incomplete<T> {
    pub d: T,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Untemplated;
impl ::std::clone::Clone for Untemplated {
    fn clone(&self) -> Self { *self }
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Templated<T> {
    pub m_untemplated: Untemplated,
    pub _phantom0: ::std::marker::PhantomData<T>,
}
/**
 * If the replacement doesn't happen at the parse level the container would be
 * copy and the replacement wouldn't, so this wouldn't compile.
 *
 * <div rustbindgen replaces="ReplacedWithoutDestructor"></div>
 */
#[repr(C)]
#[derive(Debug)]
pub struct ReplacedWithoutDestructor<T> {
    pub buff: *mut T,
}
/**
 * If the replacement doesn't happen at the parse level the container would be
 * copy and the replacement wouldn't, so this wouldn't compile.
 *
 * <div rustbindgen replaces="ReplacedWithoutDestructorFwd"></div>
 */
#[repr(C)]
#[derive(Debug)]
pub struct ReplacedWithoutDestructorFwd<T> {
    pub buff: *mut T,
}
#[repr(C)]
#[derive(Debug)]
pub struct ShouldNotBeCopiable<T> {
    pub m_member: ReplacedWithoutDestructor<T>,
}
#[repr(C)]
#[derive(Debug)]
pub struct ShouldNotBeCopiableAsWell<U> {
    pub m_member: ReplacedWithoutDestructorFwd<U>,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct TemplateWithVar<T> {
    pub _phantom0: ::std::marker::PhantomData<T>,
}
extern "C" {
    #[link_name = "_Z3bar3FooIiiE"]
    pub fn bar(foo: Foo<::std::os::raw::c_int, ::std::os::raw::c_int>);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Foo<T> {
    pub m_member: T,
}
extern "C" {
    #[link_name = "_Z3bar3FooIiE"]
    pub fn bar(foo: Foo<::std::os::raw::c_int>);
}
thread 'test_cxx::test_cxx_template' panicked at 'explicit panic', tests/support.rs:66

---- test_cxx::test_cxx_class stdout ----
    Generated bindings for headers/class.hpp do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Copy)]
pub struct C {
    pub a: ::std::os::raw::c_int,
    pub big_array: [::std::os::raw::c_char; 33usize],
}
impl ::std::clone::Clone for C {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_C() {
    assert_eq!(::std::mem::size_of::<C>() , 40usize);
    assert_eq!(::std::mem::align_of::<C>() , 4usize);
}
#[repr(C)]
#[derive(Debug)]
pub struct WithDtor {
    pub b: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_WithDtor() {
    assert_eq!(::std::mem::size_of::<WithDtor>() , 4usize);
    assert_eq!(::std::mem::align_of::<WithDtor>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union {
    pub d: __BindgenUnionField<f32>,
    pub i: __BindgenUnionField<::std::os::raw::c_int>,
    pub _bindgen_data_: u32,
}
impl Union {
    pub unsafe fn d(&mut self) -> *mut f32 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn i(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union() {
    assert_eq!(::std::mem::size_of::<Union>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct WithUnion {
    pub data: Union,
}
impl ::std::clone::Clone for WithUnion {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_WithUnion() {
    assert_eq!(::std::mem::size_of::<WithUnion>() , 4usize);
    assert_eq!(::std::mem::align_of::<WithUnion>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct C {
    pub a: ::std::os::raw::c_int,
}
thread 'test_cxx::test_cxx_class' panicked at 'explicit panic', tests/support.rs:66

---- test_func::func_ptr_in_struct stdout ----
    Generated bindings for headers/func_ptr_in_struct.h do not match the reference bindings.

Generated:

#[repr(i32)]
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum Enum_baz { _BindgenOpaqueEnum = 0, }
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_Foo {
    pub bar: ::std::option::Option<unsafe extern "C" fn(x:
                                                            ::std::os::raw::c_int,
                                                        y:
                                                            ::std::os::raw::c_int)
                                       -> Enum_baz>,
}
impl ::std::clone::Clone for Struct_Foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_Foo() {
    assert_eq!(::std::mem::size_of::<Struct_Foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_Foo>() , 8usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_Foo {
    pub bar: ::std::option::Option<unsafe extern "C" fn(x:
                                                            ::std::os::raw::c_int,
                                                        y:
                                                            ::std::os::raw::c_int)
                                       -> Enum_baz>,
}
thread 'test_func::func_ptr_in_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::containing_fwd_decl_struct stdout ----
    Generated bindings for headers/struct_containing_forward_declared_struct.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_a {
    pub val_a: *mut Struct_b,
}
impl ::std::clone::Clone for Struct_a {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_a() {
    assert_eq!(::std::mem::size_of::<Struct_a>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_a>() , 8usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_b {
    pub val_b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for Struct_b {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_b() {
    assert_eq!(::std::mem::size_of::<Struct_b>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_b>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_a {
    pub val_a: *mut Struct_b,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_b {
    pub val_b: ::std::os::raw::c_int,
}
thread 'test_struct::containing_fwd_decl_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::packed_struct stdout ----
    Generated bindings for headers/struct_with_packing.h do not match the reference bindings.

Generated:

#[repr(C, packed)]
#[derive(Debug, Copy)]
pub struct Struct_a {
    pub b: ::std::os::raw::c_char,
    pub c: ::std::os::raw::c_short,
}
impl ::std::clone::Clone for Struct_a {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_a() {
    assert_eq!(::std::mem::size_of::<Struct_a>() , 3usize);
    assert_eq!(::std::mem::align_of::<Struct_a>() , 1usize);
}

Reference:

#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct Struct_a {
    pub b: ::std::os::raw::c_char,
    pub c: ::std::os::raw::c_short,
}
thread 'test_struct::packed_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_struct_pointer stdout ----
    Generated bindings for headers/struct_with_anon_struct_pointer.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub bar: *mut Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_pointer_h_unnamed_1>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 8usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_foo {
    pub bar: *mut Struct_struct_with_anon_struct_pointer_h_unnamed_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_struct_with_anon_struct_pointer_h_unnamed_1 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
thread 'test_struct::with_anon_struct_pointer' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_struct stdout ----
    Generated bindings for headers/struct_with_anon_struct.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub bar: Struct_foo_struct_with_anon_struct_h_unnamed_4,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_anon_struct_h_unnamed_4 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for Struct_foo_struct_with_anon_struct_h_unnamed_4 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_h_unnamed_4() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_h_unnamed_4>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_h_unnamed_4>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_foo {
    pub bar: Struct_struct_with_anon_struct_h_unnamed_1,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_struct_with_anon_struct_h_unnamed_1 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
thread 'test_struct::with_anon_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_struct_array stdout ----
    Generated bindings for headers/struct_with_anon_struct_array.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub bar: [Struct_foo_struct_with_anon_struct_array_h_unnamed_2; 2usize],
    pub baz: [[[Struct_foo_struct_with_anon_struct_array_h_unnamed_3; 4usize]; 3usize]; 2usize],
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_2 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_anon_struct_array_h_unnamed_2 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_array_h_unnamed_2() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_2>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_2>()
               , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_anon_struct_array_h_unnamed_3 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_anon_struct_array_h_unnamed_3 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_anon_struct_array_h_unnamed_3() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_3>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_struct_array_h_unnamed_3>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 208usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_foo {
    pub bar: [Struct_struct_with_anon_struct_array_h_unnamed_1; 2usize],
    pub baz: [[[Struct_struct_with_anon_struct_array_h_unnamed_2; 4usize]; 3usize]; 2usize],
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_struct_with_anon_struct_array_h_unnamed_1 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_struct_with_anon_struct_array_h_unnamed_2 {
    pub a: ::std::os::raw::c_int,
    pub b: ::std::os::raw::c_int,
}
thread 'test_struct::with_anon_struct_array' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_unnamed_struct stdout ----
    Generated bindings for headers/struct_with_anon_unnamed_struct.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub foo_struct_with_anon_unnamed_struct_h_unnamed_7: Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7 {
    pub a: ::std::os::raw::c_uint,
    pub b: ::std::os::raw::c_uint,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_anon_unnamed_struct_h_unnamed_7>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Struct_foo {
    pub _bindgen_data_1_: [u32; 2usize],
}
impl Struct_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(4))
    }
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_struct::with_anon_unnamed_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_union stdout ----
    Generated bindings for headers/struct_with_anon_union.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub bar: Union_foo_struct_with_anon_union_h_unnamed_5,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_struct_with_anon_union_h_unnamed_5 {
    pub a: __BindgenUnionField<::std::os::raw::c_uint>,
    pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub _bindgen_data_: u32,
}
impl Union_foo_struct_with_anon_union_h_unnamed_5 {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo_struct_with_anon_union_h_unnamed_5 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_struct_with_anon_union_h_unnamed_5() {
    assert_eq!(::std::mem::size_of::<Union_foo_struct_with_anon_union_h_unnamed_5>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo_struct_with_anon_union_h_unnamed_5>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_foo {
    pub bar: Union_unnamed1,
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct Union_unnamed1 {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_unnamed1 {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
thread 'test_struct::with_anon_union' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_anon_unnamed_union stdout ----
    Generated bindings for headers/struct_with_anon_unnamed_union.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub foo_struct_with_anon_unnamed_union_h_unnamed_6: Union_foo_struct_with_anon_unnamed_union_h_unnamed_6,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_struct_with_anon_unnamed_union_h_unnamed_6 {
    pub a: __BindgenUnionField<::std::os::raw::c_uint>,
    pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub _bindgen_data_: u32,
}
impl Union_foo_struct_with_anon_unnamed_union_h_unnamed_6 {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for
 Union_foo_struct_with_anon_unnamed_union_h_unnamed_6 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_struct_with_anon_unnamed_union_h_unnamed_6() {
    assert_eq!(::std::mem::size_of::<Union_foo_struct_with_anon_unnamed_union_h_unnamed_6>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo_struct_with_anon_unnamed_union_h_unnamed_6>()
               , 4usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_foo {
    pub _bindgen_data_1_: [u32; 1usize],
}
impl Struct_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_struct::with_anon_unnamed_union' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_fwd_decl_struct stdout ----
    Generated bindings for headers/forward_declared_struct.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_a {
    pub b: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for Struct_a {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_a() {
    assert_eq!(::std::mem::size_of::<Struct_a>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_a>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_c {
    pub d: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for Struct_c {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_c() {
    assert_eq!(::std::mem::size_of::<Struct_c>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_c>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_a {
    pub b: ::std::os::raw::c_int,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Struct_c {
    pub d: ::std::os::raw::c_int,
}
thread 'test_struct::with_fwd_decl_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_anon_struct stdout ----
    Generated bindings for headers/union_with_anon_struct.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo {
    pub bar: __BindgenUnionField<Struct_foo_union_with_anon_struct_h_unnamed_10>,
    pub _bindgen_data_: [u32; 2usize],
}
impl Union_foo {
    pub unsafe fn bar(&mut self)
     -> *mut Struct_foo_union_with_anon_struct_h_unnamed_10 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo() {
    assert_eq!(::std::mem::size_of::<Union_foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_union_with_anon_struct_h_unnamed_10 {
    pub a: ::std::os::raw::c_uint,
    pub b: ::std::os::raw::c_uint,
}
impl ::std::clone::Clone for Struct_foo_union_with_anon_struct_h_unnamed_10 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_union_with_anon_struct_h_unnamed_10() {
    assert_eq!(::std::mem::size_of::<Struct_foo_union_with_anon_struct_h_unnamed_10>()
               , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_union_with_anon_struct_h_unnamed_10>()
               , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_foo {
    pub _bindgen_data_: [u32; 2usize],
}
impl Union_foo {
    pub unsafe fn bar(&mut self) -> *mut Struct_Unnamed1 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Struct_Unnamed1 {
    pub a: ::std::os::raw::c_uint,
    pub b: ::std::os::raw::c_uint,
}
impl ::std::clone::Clone for Struct_Unnamed1 {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_Unnamed1 {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_anon_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_bitfields stdout ----
    Generated bindings for headers/struct_with_bitfields.h do not match the reference bindings.

Generated:

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_bitfield {
    pub _bitfield_1: ::std::os::raw::c_ushort,
    pub e: ::std::os::raw::c_int,
    pub _bitfield_2: ::std::os::raw::c_uint,
    pub _bitfield_3: ::std::os::raw::c_uint,
}
impl Struct_bitfield {
    #[inline]
    pub fn a(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (1usize as ::std::os::raw::c_ushort)) >> 0usize
    }
    #[inline]
    pub fn set_a(&mut self, val: bool) {
        self._bitfield_1 &= !(1usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 0usize) &
                (1usize as ::std::os::raw::c_ushort);
    }
    #[inline]
    pub fn b(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (2usize as ::std::os::raw::c_ushort)) >> 1usize
    }
    #[inline]
    pub fn set_b(&mut self, val: bool) {
        self._bitfield_1 &= !(2usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 1usize) &
                (2usize as ::std::os::raw::c_ushort);
    }
    #[inline]
    pub fn c(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (4usize as ::std::os::raw::c_ushort)) >> 2usize
    }
    #[inline]
    pub fn set_c(&mut self, val: bool) {
        self._bitfield_1 &= !(4usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 2usize) &
                (4usize as ::std::os::raw::c_ushort);
    }
    #[inline]
    pub fn at_offset_3(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (8usize as ::std::os::raw::c_ushort)) >> 3usize
    }
    #[inline]
    pub fn set_at_offset_3(&mut self, val: bool) {
        self._bitfield_1 &= !(8usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 3usize) &
                (8usize as ::std::os::raw::c_ushort);
    }
    #[inline]
    pub fn at_offset_4(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (48usize as ::std::os::raw::c_ushort)) >> 4usize
    }
    #[inline]
    pub fn set_at_offset_4(&mut self, val: u8) {
        self._bitfield_1 &= !(48usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 4usize) &
                (48usize as ::std::os::raw::c_ushort);
    }
    #[inline]
    pub fn d(&self) -> ::std::os::raw::c_ushort {
        (self._bitfield_1 & (192usize as ::std::os::raw::c_ushort)) >> 6usize
    }
    #[inline]
    pub fn set_d(&mut self, val: u8) {
        self._bitfield_1 &= !(192usize as ::std::os::raw::c_ushort);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_ushort) << 6usize) &
                (192usize as ::std::os::raw::c_ushort);
    }
    pub const fn new_bitfield_1(a: bool, b: bool, c: bool,
                                unnamed_bitfield1: bool,
                                unnamed_bitfield2: u8, d: u8)
     -> ::std::os::raw::c_ushort {
        0 | ((a as ::std::os::raw::c_ushort) << 0u32) |
            ((b as ::std::os::raw::c_ushort) << 1u32) |
            ((c as ::std::os::raw::c_ushort) << 2u32) |
            ((unnamed_bitfield1 as ::std::os::raw::c_ushort) << 3u32) |
            ((unnamed_bitfield2 as ::std::os::raw::c_ushort) << 4u32) |
            ((d as ::std::os::raw::c_ushort) << 6u32)
    }
    #[inline]
    pub fn f(&self) -> ::std::os::raw::c_uint {
        (self._bitfield_2 & (3usize as ::std::os::raw::c_uint)) >> 0usize
    }
    #[inline]
    pub fn set_f(&mut self, val: u8) {
        self._bitfield_2 &= !(3usize as ::std::os::raw::c_uint);
        self._bitfield_2 |=
            ((val as ::std::os::raw::c_uint) << 0usize) &
                (3usize as ::std::os::raw::c_uint);
    }
    pub const fn new_bitfield_2(f: u8) -> ::std::os::raw::c_uint {
        0 | ((f as ::std::os::raw::c_uint) << 0u32)
    }
    #[inline]
    pub fn g(&self) -> ::std::os::raw::c_uint {
        (self._bitfield_3 & (4294967295usize as ::std::os::raw::c_uint)) >>
            0usize
    }
    #[inline]
    pub fn set_g(&mut self, val: u32) {
        self._bitfield_3 &= !(4294967295usize as ::std::os::raw::c_uint);
        self._bitfield_3 |=
            ((val as ::std::os::raw::c_uint) << 0usize) &
                (4294967295usize as ::std::os::raw::c_uint);
    }
    pub const fn new_bitfield_3(g: u32) -> ::std::os::raw::c_uint {
        0 | ((g as ::std::os::raw::c_uint) << 0u32)
    }
}
impl ::std::clone::Clone for Struct_bitfield {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_bitfield() {
    assert_eq!(::std::mem::size_of::<Struct_bitfield>() , 16usize);
    assert_eq!(::std::mem::align_of::<Struct_bitfield>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Struct_bitfield {
    pub _bindgen_bitfield_1_: ::std::os::raw::c_ushort,
    pub e: ::std::os::raw::c_int,
    pub _bindgen_bitfield_2_: ::std::os::raw::c_uint,
    pub _bindgen_bitfield_3_: ::std::os::raw::c_uint,
}
impl ::std::clone::Clone for Struct_bitfield {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_bitfield {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_struct::with_bitfields' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_anon_struct_bitfield stdout ----
    Generated bindings for headers/union_with_anon_struct_bitfield.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo {
    pub a: __BindgenUnionField<::std::os::raw::c_int>,
    pub foo_union_with_anon_struct_bitfield_h_unnamed_12: __BindgenUnionField<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12>,
    pub _bindgen_data_: u32,
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn foo_union_with_anon_struct_bitfield_h_unnamed_12(&mut self)
     -> *mut Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo() {
    assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12 {
    pub _bitfield_1: ::std::os::raw::c_int,
}
impl Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12 {
    #[inline]
    pub fn b(&self) -> ::std::os::raw::c_int {
        (self._bitfield_1 & (127usize as ::std::os::raw::c_int)) >> 0usize
    }
    #[inline]
    pub fn set_b(&mut self, val: u8) {
        self._bitfield_1 &= !(127usize as ::std::os::raw::c_int);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_int) << 0usize) &
                (127usize as ::std::os::raw::c_int);
    }
    #[inline]
    pub fn c(&self) -> ::std::os::raw::c_int {
        (self._bitfield_1 & (4294967168usize as ::std::os::raw::c_int)) >>
            7usize
    }
    #[inline]
    pub fn set_c(&mut self, val: u32) {
        self._bitfield_1 &= !(4294967168usize as ::std::os::raw::c_int);
        self._bitfield_1 |=
            ((val as ::std::os::raw::c_int) << 7usize) &
                (4294967168usize as ::std::os::raw::c_int);
    }
    pub const fn new_bitfield_1(b: u8, c: u32) -> ::std::os::raw::c_int {
        0 | ((b as ::std::os::raw::c_int) << 0u32) |
            ((c as ::std::os::raw::c_int) << 7u32)
    }
}
impl ::std::clone::Clone for
 Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12() {
    assert_eq!(::std::mem::size_of::<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_union_with_anon_struct_bitfield_h_unnamed_12>()
               , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_foo {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_anon_struct_bitfield' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_anon_union stdout ----
    Generated bindings for headers/union_with_anon_union.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo {
    pub bar: __BindgenUnionField<Union_foo_union_with_anon_union_h_unnamed_13>,
    pub _bindgen_data_: u32,
}
impl Union_foo {
    pub unsafe fn bar(&mut self)
     -> *mut Union_foo_union_with_anon_union_h_unnamed_13 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo() {
    assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_union_with_anon_union_h_unnamed_13 {
    pub a: __BindgenUnionField<::std::os::raw::c_uint>,
    pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub _bindgen_data_: u32,
}
impl Union_foo_union_with_anon_union_h_unnamed_13 {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo_union_with_anon_union_h_unnamed_13 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_union_with_anon_union_h_unnamed_13() {
    assert_eq!(::std::mem::size_of::<Union_foo_union_with_anon_union_h_unnamed_13>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo_union_with_anon_union_h_unnamed_13>()
               , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_foo {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_foo {
    pub unsafe fn bar(&mut self) -> *mut Union_Unnamed1 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_Unnamed1 {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_Unnamed1 {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_Unnamed1 {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_Unnamed1 {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_anon_union' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_anon_unnamed_struct stdout ----
    Generated bindings for headers/union_with_anon_unnamed_struct.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_pixel {
    pub rgba: __BindgenUnionField<::std::os::raw::c_uint>,
    pub pixel_union_with_anon_unnamed_struct_h_unnamed_14: __BindgenUnionField<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14>,
    pub _bindgen_data_: u32,
}
impl Union_pixel {
    pub unsafe fn rgba(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn pixel_union_with_anon_unnamed_struct_h_unnamed_14(&mut self)
     -> *mut Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_pixel {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_pixel() {
    assert_eq!(::std::mem::size_of::<Union_pixel>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union_pixel>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14 {
    pub r: ::std::os::raw::c_uchar,
    pub g: ::std::os::raw::c_uchar,
    pub b: ::std::os::raw::c_uchar,
    pub a: ::std::os::raw::c_uchar,
}
impl ::std::clone::Clone for
 Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14() {
    assert_eq!(::std::mem::size_of::<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_pixel_union_with_anon_unnamed_struct_h_unnamed_14>()
               , 1usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_pixel {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_pixel {
    pub unsafe fn rgba(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn r(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn g(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(1))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(2))
    }
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(3))
    }
}
impl ::std::clone::Clone for Union_pixel {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_pixel {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_anon_unnamed_struct' panicked at 'explicit panic', tests/support.rs:66

---- test_struct::with_nesting stdout ----
    Generated bindings for headers/struct_with_nesting.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo {
    pub a: ::std::os::raw::c_uint,
    pub foo_struct_with_nesting_h_unnamed_8: Union_foo_struct_with_nesting_h_unnamed_8,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_struct_with_nesting_h_unnamed_8 {
    pub b: __BindgenUnionField<::std::os::raw::c_uint>,
    pub foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9: __BindgenUnionField<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9>,
    pub foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11: __BindgenUnionField<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11>,
    pub _bindgen_data_: u32,
}
impl Union_foo_struct_with_nesting_h_unnamed_8 {
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9(&mut self)
     ->
         *mut Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11(&mut self)
     ->
         *mut Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo_struct_with_nesting_h_unnamed_8 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_struct_with_nesting_h_unnamed_8() {
    assert_eq!(::std::mem::size_of::<Union_foo_struct_with_nesting_h_unnamed_8>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo_struct_with_nesting_h_unnamed_8>()
               , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9 {
    pub c1: ::std::os::raw::c_ushort,
    pub c2: ::std::os::raw::c_ushort,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_9>()
               , 2usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11 {
    pub d1: ::std::os::raw::c_uchar,
    pub d2: ::std::os::raw::c_uchar,
    pub d3: ::std::os::raw::c_uchar,
    pub d4: ::std::os::raw::c_uchar,
}
impl ::std::clone::Clone for
 Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11() {
    assert_eq!(::std::mem::size_of::<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_struct_with_nesting_h_unnamed_8_struct_with_nesting_h_unnamed_11>()
               , 1usize);
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo() {
    assert_eq!(::std::mem::size_of::<Struct_foo>() , 8usize);
    assert_eq!(::std::mem::align_of::<Struct_foo>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Struct_foo {
    pub a: ::std::os::raw::c_uint,
    pub _bindgen_data_1_: [u32; 1usize],
}
impl Struct_foo {
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c1(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c2(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(2))
    }
    pub unsafe fn d1(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn d2(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(1))
    }
    pub unsafe fn d3(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(2))
    }
    pub unsafe fn d4(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_1_);
        ::std::mem::transmute(raw.offset(3))
    }
}
impl ::std::clone::Clone for Struct_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Struct_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_struct::with_nesting' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_anon_unnamed_union stdout ----
    Generated bindings for headers/union_with_anon_unnamed_union.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo {
    pub a: __BindgenUnionField<::std::os::raw::c_uint>,
    pub foo_union_with_anon_unnamed_union_h_unnamed_15: __BindgenUnionField<Union_foo_union_with_anon_unnamed_union_h_unnamed_15>,
    pub _bindgen_data_: u32,
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn foo_union_with_anon_unnamed_union_h_unnamed_15(&mut self)
     -> *mut Union_foo_union_with_anon_unnamed_union_h_unnamed_15 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo() {
    assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_union_with_anon_unnamed_union_h_unnamed_15 {
    pub b: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub c: __BindgenUnionField<::std::os::raw::c_uchar>,
    pub _bindgen_data_: u16,
}
impl Union_foo_union_with_anon_unnamed_union_h_unnamed_15 {
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for
 Union_foo_union_with_anon_unnamed_union_h_unnamed_15 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_union_with_anon_unnamed_union_h_unnamed_15() {
    assert_eq!(::std::mem::size_of::<Union_foo_union_with_anon_unnamed_union_h_unnamed_15>()
               , 2usize);
    assert_eq!(::std::mem::align_of::<Union_foo_union_with_anon_unnamed_union_h_unnamed_15>()
               , 2usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_foo {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c(&mut self) -> *mut ::std::os::raw::c_uchar {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_anon_unnamed_union' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_derive_debug stdout ----
    Generated bindings for headers/union_with_big_member.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Copy)]
pub struct Union_WithBigArray {
    pub a: __BindgenUnionField<::std::os::raw::c_int>,
    pub b: __BindgenUnionField<[::std::os::raw::c_int; 33usize]>,
    pub _bindgen_data_: [u32; 33usize],
}
impl Union_WithBigArray {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut [::std::os::raw::c_int; 33usize] {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_WithBigArray {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_WithBigArray() {
    assert_eq!(::std::mem::size_of::<Union_WithBigArray>() , 132usize);
    assert_eq!(::std::mem::align_of::<Union_WithBigArray>() , 4usize);
}
#[repr(C)]
#[derive(Copy)]
pub struct Union_WithBigMember {
    pub a: __BindgenUnionField<::std::os::raw::c_int>,
    pub b: __BindgenUnionField<Union_WithBigArray>,
    pub _bindgen_data_: [u32; 33usize],
}
impl Union_WithBigMember {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut Union_WithBigArray {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_WithBigMember {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_WithBigMember() {
    assert_eq!(::std::mem::size_of::<Union_WithBigMember>() , 132usize);
    assert_eq!(::std::mem::align_of::<Union_WithBigMember>() , 4usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
pub struct Union_WithBigArray {
    pub _bindgen_data_: [u32; 33usize],
}
impl Union_WithBigArray {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut [::std::os::raw::c_int; 33usize] {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_WithBigArray {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_WithBigArray {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
#[repr(C)]
#[derive(Copy)]
pub struct Union_WithBigMember {
    pub _bindgen_data_: [u32; 33usize],
}
impl Union_WithBigMember {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_int {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b(&mut self) -> *mut Union_WithBigArray {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_WithBigMember {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_WithBigMember {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_derive_debug' panicked at 'explicit panic', tests/support.rs:66

---- test_union::with_nesting stdout ----
    Generated bindings for headers/union_with_nesting.h do not match the reference bindings.

Generated:

#[derive(Copy, Debug)]
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
    #[inline]
    pub fn new() -> Self { __BindgenUnionField(::std::marker::PhantomData) }
    #[inline]
    pub unsafe fn as_ref(&self) -> &T { ::std::mem::transmute(self) }
    #[inline]
    pub unsafe fn as_mut(&mut self) -> &mut T { ::std::mem::transmute(self) }
}
impl <T> ::std::default::Default for __BindgenUnionField<T> {
    #[inline]
    fn default() -> Self { Self::new() }
}
impl <T> ::std::clone::Clone for __BindgenUnionField<T> {
    #[inline]
    fn clone(&self) -> Self { Self::new() }
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo {
    pub a: __BindgenUnionField<::std::os::raw::c_uint>,
    pub foo_union_with_nesting_h_unnamed_16: __BindgenUnionField<Struct_foo_union_with_nesting_h_unnamed_16>,
    pub _bindgen_data_: u32,
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn foo_union_with_nesting_h_unnamed_16(&mut self)
     -> *mut Struct_foo_union_with_nesting_h_unnamed_16 {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo() {
    assert_eq!(::std::mem::size_of::<Union_foo>() , 4usize);
    assert_eq!(::std::mem::align_of::<Union_foo>() , 4usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_foo_union_with_nesting_h_unnamed_16 {
    pub foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17: Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17,
    pub foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18: Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18,
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17 {
    pub b1: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub b2: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub _bindgen_data_: u16,
}
impl Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17
 {
    pub unsafe fn b1(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b2(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for
 Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17() {
    assert_eq!(::std::mem::size_of::<Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17>()
               , 2usize);
    assert_eq!(::std::mem::align_of::<Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_17>()
               , 2usize);
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18 {
    pub c1: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub c2: __BindgenUnionField<::std::os::raw::c_ushort>,
    pub _bindgen_data_: u16,
}
impl Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18
 {
    pub unsafe fn c1(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c2(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
}
impl ::std::clone::Clone for
 Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18() {
    assert_eq!(::std::mem::size_of::<Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18>()
               , 2usize);
    assert_eq!(::std::mem::align_of::<Union_foo_union_with_nesting_h_unnamed_16_union_with_nesting_h_unnamed_18>()
               , 2usize);
}
impl ::std::clone::Clone for Struct_foo_union_with_nesting_h_unnamed_16 {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_foo_union_with_nesting_h_unnamed_16() {
    assert_eq!(::std::mem::size_of::<Struct_foo_union_with_nesting_h_unnamed_16>()
               , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_foo_union_with_nesting_h_unnamed_16>()
               , 2usize);
}

Reference:

#[repr(C)]
#[derive(Copy)]
#[derive(Debug)]
pub struct Union_foo {
    pub _bindgen_data_: [u32; 1usize],
}
impl Union_foo {
    pub unsafe fn a(&mut self) -> *mut ::std::os::raw::c_uint {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b1(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn b2(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(0))
    }
    pub unsafe fn c1(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(2))
    }
    pub unsafe fn c2(&mut self) -> *mut ::std::os::raw::c_ushort {
        let raw: *mut u8 = ::std::mem::transmute(&self._bindgen_data_);
        ::std::mem::transmute(raw.offset(2))
    }
}
impl ::std::clone::Clone for Union_foo {
    fn clone(&self) -> Self { *self }
}
impl ::std::default::Default for Union_foo {
    fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
thread 'test_union::with_nesting' panicked at 'explicit panic', tests/support.rs:66


failures:
    test_builtins::test_builtin_va_list
    test_cxx::test_cxx_class
    test_cxx::test_cxx_template
    test_enum::with_duplicate_enum_value
    test_enum::with_explicitly_typed_cxx_enum
    test_enum::with_overflowed_enum_value
    test_enum::with_packed_enums
    test_enum::with_simple_enum
    test_func::func_ptr_in_struct
    test_struct::containing_fwd_decl_struct
    test_struct::packed_struct
    test_struct::with_anon_struct
    test_struct::with_anon_struct_array
    test_struct::with_anon_struct_pointer
    test_struct::with_anon_union
    test_struct::with_anon_unnamed_struct
    test_struct::with_anon_unnamed_union
    test_struct::with_bitfields
    test_struct::with_fwd_decl_struct
    test_struct::with_nesting
    test_union::with_anon_struct
    test_union::with_anon_struct_bitfield
    test_union::with_anon_union
    test_union::with_anon_unnamed_struct
    test_union::with_anon_unnamed_union
    test_union::with_derive_debug
    test_union::with_nesting

test result: FAILED. 6 passed; 27 failed; 0 ignored; 0 measured

error: test failed

Bindgen doesn't work on with MSVC

I tried to investigate this, but failed. It throws lots of errors. See the attached log: bindgen.zip

This log gives me an impression that it just fails to parse everything.

My Clang version is:

clang version 3.9.0 (branches/release_39)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: c:\Program Files\LLVM\bin

Template specialization

Hi,
bindgen ignore template specialization for class (and struct) and select the first "working answer".
For example :

template <typename T>
class test;

template<>
class test<int> {
    int foo;
};
template<>
class test<float> {
    float foo;
};

give

test.hpp:1:9: warning: #pragma once in main file [-Wpragma-once-outside-header]
/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy)]
pub struct Struct_test {
    pub foo: ::std::os::raw::c_int,
}
impl ::std::clone::Clone for Struct_test {
    fn clone(&self) -> Self { *self }
}
#[test]
fn bindgen_test_layout_Struct_test() {
    assert_eq!(::std::mem::size_of::<Struct_test>() , 4usize);
    assert_eq!(::std::mem::align_of::<Struct_test>() , 4usize);
}

The float specialization is ignored.
And with a valid test<T>:

template <typename T>
class test{};

template<>
class test<int> {
    int foo;
};
template<>
class test<float> {
    float foo;
};

gives :

test.hpp:1:9: warning: #pragma once in main file [-Wpragma-once-outside-header]
/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Struct_test<T> {
    pub _phantom0: ::std::marker::PhantomData<T>,
}

Both the float and int specialization are ignored.

Class local typedefs don't get generated

In mfbt/UniquePtr.h:

template<typename T, class D>
class UniquePtr
{
public:
  typedef T ElementType;
  typedef D DeleterType;
  typedef typename detail::PointerType<T, DeleterType>::Type Pointer;

private:
  Pair<Pointer, DeleterType> mTuple;

  ...
};

In the generated bindings:

#[repr(C)]
#[unsafe_no_drop_flag]
#[derive(Debug)]
pub struct UniquePtr<T, D> {
    pub mTuple: Pair<Pointer, DeleterType>,
    pub _phantom0: ::std::marker::PhantomData<T>,
    pub _phantom1: ::std::marker::PhantomData<D>,
}

Resulting errors:

src/jsapi_linux_64_debug.rs:225:22: 225:29 error: type name `Pointer` is undefined or not in scope [E0412]
src/jsapi_linux_64_debug.rs:225     pub mTuple: Pair<Pointer, DeleterType>,
                                                     ^~~~~~~
src/lib.rs:52:5: 52:41 note: in this expansion of include!
src/jsapi_linux_64_debug.rs:225:22: 225:29 help: run `rustc --explain E0412` to see a detailed explanation
src/jsapi_linux_64_debug.rs:225:22: 225:29 help: you can import it into scope: `use std::fmt::Pointer;`. 
src/jsapi_linux_64_debug.rs:225:31: 225:42 error: type name `DeleterType` is undefined or not in scope [E0412]
src/jsapi_linux_64_debug.rs:225     pub mTuple: Pair<Pointer, DeleterType>,
                                                              ^~~~~~~~~~~
src/lib.rs:52:5: 52:41 note: in this expansion of include!
src/jsapi_linux_64_debug.rs:225:31: 225:42 help: run `rustc --explain E0412` to see a detailed explanation
src/jsapi_linux_64_debug.rs:225:31: 225:42 help: no candidates by the name of `DeleterType` found in your project; maybe you misspelled the name or forgot to import an external crate? 

current bindgen is broken for rust-mozjs

It reports an error about the copyability of inlineStorageLatin1, but the real problem appears to be that while it translated the Latin1Char type correctly, inside the unions it just has them as c_void.

Segfault with CRTP

Hi,
using bindgen on a C++ template using CRTP result in a segfault.

The C++ file :

template<class T>
class Base {};

class Derived : public Base<Derived> {};

I have libclang v3.8.0 and rustc v1.9.0 and I'm on Manjaro Linux (linux distribution based on Arch Linux).

Add CONTRIBUTING.md file

Should have info for people hacking on bindgen (whereas README.md is more for users of bindgen / landing page).

As a newcomer, I'd really like to have an architectural overview of the project.

Failure to build with llvm_stable on OSX

Having trouble building on OSX with llvm 3.8 (installed via brew install llvm38 as suggested in the README).

Perhaps rust-bindgen requires llvm 3.9 now?

$ cargo build --features llvm_stable
cargo build --features llvm_stable
    Updating registry `https://github.com/rust-lang/crates.io-index`
 Downloading aster v0.21.1
 Downloading syntex_syntax v0.38.0
 Downloading quasi v0.15.0
 Downloading syntex_errors v0.38.0
 Downloading syntex_pos v0.38.0
 Downloading quasi_codegen v0.15.0
 Downloading syntex v0.38.0
   Compiling unicode-xid v0.0.3
   Compiling winapi v0.2.8
   Compiling log v0.3.6
   Compiling bitflags v0.5.0
   Compiling winapi-build v0.1.1
   Compiling rustc-serialize v0.3.19
   Compiling libc v0.2.14
   Compiling glob v0.2.11
   Compiling bitflags v0.7.0
   Compiling kernel32-sys v0.2.2
   Compiling term v0.4.4
   Compiling clang-sys v0.7.2
   Compiling syntex_pos v0.38.0
   Compiling syntex_errors v0.38.0
   Compiling syntex_syntax v0.38.0
   Compiling quasi v0.15.0
   Compiling syntex v0.38.0
   Compiling aster v0.21.1
   Compiling quasi_codegen v0.15.0
   Compiling bindgen v0.16.0 (file:///Users/fitzgen/src/rust-bindgen)
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib" "/Users/fitzgen/src/rust-bindgen/target/debug/bindgen.0.o" "-o" "/Users/fitzgen/src/rust-bindgen/target/debug/bindgen" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/fitzgen/src/rust-bindgen/target/debug" "-L" "/Users/fitzgen/src/rust-bindgen/target/debug/deps" "-L" "/Library/Developer/CommandLineTools/usr/lib" "-L" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib" "/Users/fitzgen/src/rust-bindgen/target/debug/libbindgen.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libaster-aa20364fcf697ecb.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libclang_sys-339b6a7941ab49bd.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libglob-0ffe4874535835d5.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libbitflags-10d625c8a1ca3e9d.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libquasi-9b17a07dc016f11f.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libsyntex_syntax-d9b67e80d0879932.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libbitflags-e87d150db0333415.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libsyntex_errors-c067eab8d7579d53.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libterm-585dc449d37783e7.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/liblog-342ffb7444a9471d.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libsyntex_pos-303d294289b89367.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/librustc_serialize-3bc953984ed46e7f.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/liblibc-87e81dcd3af1ebe2.rlib" "/Users/fitzgen/src/rust-bindgen/target/debug/deps/libunicode_xid-eb07034761892aae.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/libstd-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/libcollections-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/librustc_unicode-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/librand-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/liballoc-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/liballoc_jemalloc-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/liblibc-d16b8f0e.rlib" "/Users/fitzgen/.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib/libcore-d16b8f0e.rlib" "-l" "clang" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-Wl,-rpath,@loader_path/../../../../.multirust/toolchains/stable/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-rpath,/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-l" "compiler-rt"
note: Undefined symbols for architecture x86_64:
  "_clang_CXXField_isMutable", referenced from:
      bindgen::clang::Cursor::is_mutable_field::hd4d8240c77b7b6c9 in libbindgen.rlib(bindgen.0.o)
  "_clang_getCursorVisibility", referenced from:
      bindgen::clang::Cursor::visibility::h46761707eff6a2de in libbindgen.rlib(bindgen.0.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
error: Could not compile `bindgen`.

To learn more, run the command again with --verbose.

Generate layout tests for template specializations.

Right now we don't generate layout tests for types with template parameters for obvious reasons. The bindgen rewrite tracks all the template specializations, so we can start generating layout tests for them.

Document `-blacklist-type SomeType`

JS_DefaultLocale returns UniqueChars

Added -blacklist-type UniqueChars to rust-mozjs's etc/bindings.sh

Regenerated bindings

bindgen is still generating a binding for JS_DefaultLocale

Make 'cargo test' work

At least some of the reason is that 9f78ea9 did not update test expectations.

Once this is fixed, cargo test should be added to .travis.yml.

Build on stable rust.

Stylo needs this in order to not introduce a binary dependency, and this probably also comes handy for SM (cc @fitzgen).

I'm working on this.

Generate methods that invoke vtable pointers

We generate glue for C++ classes with virtual tables (for example, CustomAutoRooter in rust-mozjs), but we don't generate methods that fetch the function pointer from the vtable and invoke it with the this pointer. That would be a significant improvement in usability.

stack overflow when building

Or is this a rustc bug?

fitzgen@nfitzgerald-22150 :: (master) :: ~/src/rust-bindgen
    $ cargo build
   Compiling libc v0.2.14
   Compiling log v0.3.6
   Compiling winapi-build v0.1.1
   Compiling bitflags v0.5.0
   Compiling rustc-serialize v0.3.19
   Compiling unicode-xid v0.0.3
   Compiling bitflags v0.7.0
   Compiling glob v0.2.11
   Compiling winapi v0.2.8
   Compiling kernel32-sys v0.2.2
   Compiling term v0.4.4
   Compiling clang-sys v0.8.1
   Compiling syntex_pos v0.38.0
   Compiling syntex_errors v0.38.0
   Compiling syntex_syntax v0.38.0
   Compiling aster v0.21.1
   Compiling syntex v0.38.0
   Compiling quasi v0.15.0
   Compiling quasi_codegen v0.15.0
   Compiling bindgen v0.16.0 (file:///Users/fitzgen/src/rust-bindgen)
error: failed to run custom build command for `bindgen v0.16.0 (file:///Users/fitzgen/src/rust-bindgen)`
process didn't exit successfully: `/Users/fitzgen/src/rust-bindgen/target/debug/build/bindgen-e1c55643d1fbc581/build-script-build` (signal: 6, SIGABRT: process abort signal)
--- stderr

thread 'main' has overflowed its stack
fatal runtime error: stack overflow


fitzgen@nfitzgerald-22150 :: (master) :: ~/src/rust-bindgen
    $ git log -1
commit 2d943478573dc85dddb232cf0e82908a5a4c00ea
Merge: f64606f 5c67b7d
Author: bors-servo <[email protected]>
Date:   Thu Aug 18 23:40:00 2016 -0500

    Auto merge of #34 - upsuper:blacklist-typedef, r=emilio

    Allow blacklist typedef

    This allows making type aliases to be blacklisted.

fitzgen@nfitzgerald-22150 :: (master) :: ~/src/rust-bindgen
    $ cargo --version
cargo 0.13.0-nightly (4c21961 2016-08-17)

fitzgen@nfitzgerald-22150 :: (master) :: ~/src/rust-bindgen
    $ rustc --version
rustc 1.13.0-nightly (aef6971ca 2016-08-17)

Generate pub const for most of anonymous enums

Anonymous enums usually serve as a container of scoped constants without linkage. It is more useful to have a pub const for each of its members, rather than an enum with some unique name.

Discussed this with @Manishearth on IRC, and he prefers having enum because that fits matching better. However, in majority of cases, you cannot get a variable with its type being an anonymous enum, which means you need a manual conversion anyway. And that manual conversion requires the knowledge of the name of the enum in binding, which is volatile.

There is one case, though, you can get a variable with an anonymous enum type, that someone writes enum { XXX } var, in which case @Manishearth's argument makes lots of sense. So I suggest that for all other cases, we generate pub consts rather than enums.

Integer type not generated properly when it's a template argument

If I have a type nsTArray<uint16_t>, it is expected that I would get nsTArray<u16> from bindgen. However, I get nsTArray<::std::os::raw::c_ushort> instead.

It seems the uint16_t-to-u16 conversion is done in type_from_named inside codegen mod. I suspect that the uint16_t in template argument list is converted to unsigned short in parsing phase, and consequently codegen has nothing to do with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.