bindgen -v
without an input header argument.ParseCallbacks::header_file
callback which runs on every filename passed to Builder::header
.CargoCallbacks::new
constructor which emits a cargo-rerun line for every input header file by default.CargoCallbacks::rerun_on_header_files
method to configure whether a cargo-rerun line should be emitted for every input header file.--wrap-static-fns
feature was updated so function types that has no argument use void
as its sole argument.CargoCallbacks
is no longer a unit-like struct and the CargoCallbacks
constant was added to mitigate the breaking nature of this change. This constant has been marked as deprecated and users will have to use the new CargoCallbacks::new
method in the future.bindgen-cli
with a static libclang.Self
, self
, crate
or super
.system
ABI is now supported as an option for the --override-abi
flag.allowlist_item
method and the --allowlist-item
flag have been included to filter items regardless or their kind.Clone
implementation for _BindgenUnionField
has been changed to pass the incorrect_clone_impl_on_copy_type
Clippy lint.c_unwind
ABI can be used without a feature gate for any Rust target version equal to or greater than 1.71. This comes as a result of the ABI being stabilised (in Rust 1.71).CStr
constants when using the --generate-cstr
option.extra_assert
and extra_assert_eq
macros are no longer exported.self
, crate
, super
or Self
.This version was skipped due to some problems on the release workflow.
--generate-cstr
CLI flag to generate string constants as &CStr
instead of &[u8]
. (Requires Rust 1.59 or higher.)--generate-shell-completions
CLI flag to generate completions for different shells.--wrap-static-fns
option can now wrap va_list
functions as variadic functions with the experimental ParseCallbacks::wrap_as_variadic_fn
method.ParseCallbacks::field_visibility
method to modify field visibility.&[u8; SIZE]
) instead of arrays ([u8; SIZE]
) to match UTF-8 strings.void
no longer contain a return
statement and only call the static function instead.--wrap-static-fns
option no longer emits wrappers for static variadic functions.--depfile
or Builder::depfile
will now properly generate module names and paths that include spaces by escaping them. To make the escaping clear and consistent, backslashes are also escaped.bitflags
dependency to 2.2.1. This changes the API of CodegenConfig
.bindgen
as a library._bindgen_*
names having a different index.Remove redundant Cargo features, which were all implicit:
env_logger
and log
removed in favor of logging
log
removed in favor of logging
which
removed in favor of which-logging
annotate-snippets
removed in favor of experimental
Prettyplease is available as a Formatter
variant now.
Builder::rustfmt_bindings
method was added back and tagged as deprecated instead of being removed.Builder::default_visibility
method and the --default-visibility
flag to set the default visibility of fields. (#2338)--formatter
CLI flag with the values none
, rustfmt
and prettyplease
to select which tool will be used to format the bindings. The default value is rustfmt
. (#2453)Builder::formatter
method and the Formatter
type to select which tool will be used to format the bindings. (#2453)Builder::emit_diagnostics
method and the --emit-diagnostics
flag to enable emission of diagnostic messages under the experimental
feature. (#2436)"efiapi"
calling convention (#2490).ParseCallbacks::read_env_var
method which runs everytime bindgen
reads and environment variable. (#2400)ParseCallbacks::generated_link_name_override
method which allow overriding the link name of items. (#2425)enum
s when generating code while using the --wrap-static-fns
feature. (#2415)void
as their single argument instead of having no arguments when the --wrap-static-fns
flag is used. (#2443)--wrap-static-fns
flag is enabled now contains #include
directives with all the input headers and all the source code added with the header_contents
method. (#2447)--wrap-static-fns
flag no longer uses asm
labeling and the link name of static wrapper functions is allowed to be mangled. (#2448)type
aliases now matches the comments of their typedef
counterparts instead of using the comments of the aliased types. (#2463)Builder::rustfmt_bindings
methods and the --no-rustfmt-bindings
flag are now deprecated in favor of the formatter API. (#2453)--use-msvc-mangling
, --rustfmt-bindings
and --size_t-is-usize
. (#2408)Bindings::emit_warnings
and Bindings::warnings
methods were removed in favor of --emit-diagnostics
. (#2436)--with-derive-custom
, --with-derive-custom-struct
, --with-derive-custom-enum
and --with-derive-custom-enum
to add custom derives from the CLI.--experimental
flag on bindgen-cli
and the experimental
feature on bindgen
to gate experimental features whose implementation is incomplete or are prone to change in a non-backwards compatible manner.--wrap-static-fns
, --wrap-static-fns-suffix
and --wrap-static-fns-path
to generate C function wrappers for static
or static inline
functions. This feature is experimental.enum
and a typedef
with the same name.ParseCallbacks::generated_name_override
method now receives ItemInfo<'_>
as argument instead of a &str
.clang-sys
crate version to 1.4.0 to support clang 15.void
.clap
dependency for bindgen-cli
to 4.bindgen-cli
argument parser which could introduce unexpected behavior changes.ParseCallbacks::add_derives
method now receives DeriveInfo<'_>
as argument instead of a &str
. This type also includes the kind of target type.process_comments
method to the ParseCallbacks
trait to handle source code comments.--wrap_unsafe_ops
option is enabled.name: &str
argument for ParseCallbacks::add_derives
by info: DeriveInfo
.1.30
are being deprecated and will be removed in the future. If you have a good reason to use any of these targets, please report it in the issue tracker.whitelist_recursively
, hide_type
, blacklist_type
, blacklist_function
, blacklist_item
, whitelisted_type
, whitelist_type
, whitelist_function
, whitelisted_function
, whitelist_var
, whitelisted_var
, unstable_rust
.--override-abi
flag to override the ABI used by functions matching a regular expression.C-unwind
ABI in --override-abi
on nightly rust.a|b
) is handled correctly but wildcard patterns (*
) are now considered invalid. The .*
pattern can be used as a replacement.ParseCallbacks
trait does not require to implement UnwindSafe
.Builder::parse_callbacks
method no longer overwrites previously added callbacks and composes them in a last-to-first manner.Released 2022/10/16
--sort-semantically
flag to sort the output in a predefined manner (#1743).Bindgen::emit_warnings
method to emit warnings to stderr in build scripts.--newtype-global-enum
flag to generate enum variants as global constants.--default-non-copy-union-style
flag to set the default style of code used to generate unions with non-Copy
members.--bindgen-wrapper-union
flag to mark any union that matches a regex and has a non-Copy member to use a bindgen-generated wrapper for its fields.--manually-drop-union
flag to mark any union that matches a regex and has a non-Copy
member to use ManuallyDrop
.--merge-extern-blocks
flag to merge several extern
blocks that have the same ABI.--no-size_t-is-usize
flag to not bind size_t
as usize
.Builder
implements Clone
.--enable-function-attribute-detection
flag is also used to detect diverging functions so the generated bindings use !
as the return type.--size_t-is-usize
flag is enabled by default.<stdint.h>
types are no longer emitted.blocklist
options now can be used to block objective-C methods.core::ffi
module is used the sized raw integer types instead of std::os::raw
if the Rust target version is 1.64
or higher and the --use-core
flag is enabled.bindgen
CLI utility must be installed using cargo install bindgen-cli
now.bindgen
as a library no longer pulls clap and any other CLI related dependencies.Released 2022/06/06
Released 2022/06/05
Debug
and Copy
to support C and Objective-C structs. (#2176)--version --verbose
now prints clang version (#2140).--allowlist-file
option (#2122).#[macro_use]
use. (#2176)BINDGEN_EXTRA_CLANG_ARGS
is respected on the CLI now (#1723).#[must_use]
in typedefs (#2206).Released 2021/11/26
Released 2021/07/26
Released 2021/07/20
Released 2021/04/06
bindgen::Builder::whitelist_recursively
(deprecated in favor of bindgen::Builder::allowlist_recursively
). [#2022][]Released 2021/04/03
bindgen::Builder::whitelist_type
is deprecated in favor of bindgen::Builder::allowlist_type
. [#1812][]
bindgen::Builder::whitelist_function
is deprecated in favor of bindgen::Builder::allowlist_function
. [#1812][]
bindgen::Builder::whitelist_var
is deprecated in favor of bindgen::Builder::allowlist_var
. [#1812][]
--whitelist-type
is deprecated in favor of --allowlist-type
. [#1812][]
--whitelist-function
is deprecated in favor of --allowlist-function
. [#1812][]
--whitelist-var
is deprecated in favor of --allowlist-var
. [#1812][]
bindgen::Builder::blacklist_type
is deprecated in favor of bindgen::Builder::blocklist_type
. [#1812][]
bindgen::Builder::blacklist_function
is deprecated in favor of bindgen::Builder::blocklist_function
. [#1812][]
bindgen::Builder::blacklist_item
is deprecated in favor of bindgen::Builder::blocklist_item
. [#1812][]
--blacklist-type
is deprecated in favor of --blocklist-type
. [#1812][]
--blacklist-function
is deprecated in favor of --blocklist-function
. [#1812][]
--blacklist-item
is deprecated in favor of --blocklist-item
. [#1812][]
Released 2021/02/01
Released 2020/11/26
From<ChildClass> for ParentClass
as well as TryFrom<ParentClass> for ChildClass
(#1883).dynamic_library_name
(#1846).Default
on a per-struct basis (#1930).Released 2020/08/24.
Released 2020/08/23.
Added options to avoid deriving the Debug trait (#1858).
Added options to allow to override the default anonymous field prefix (#1859).
Added options to allow to override the default macro integer type from the command line (#1863).
Typed anonymous enums now generate better code (#1850).
Objective-C bindings are more idiomatic now (#1847).
Updated to clang-sys 1.0. Minimum supported rust version is 1.40 as a consequence of that change.
Fixed constness of multi-dimensional arrays in some cases (#1861).
Fixed wrong target given to clang when compiling with a target which doesn't match the target clang expects (#1870, #1878).
Fixed wrong flags being computed for cross-compilation cases where the target wasn't explicitly provided via clang flags (#1872).
Thanks again to all the awesome contributors that sent patches included in this release!
Released 2020/07/06.
Yanked: The change in #1798 is technically breaking, see PR for details.
Added ParseCallbacks::func_macro to be able to process function-like macros. (#1792).
Allowed IntKind::Custom to represent paths instead of idents (#1800).
Generated comment now includes the bindgen version, and can be disabled (#1814).
Various documentation improvements.
Typedefs for types with the same names as rust primitive types compiles (#1798).
Bindgen dependencies will now get rebuilt when various environment variables that affect bindgen change (#1809, #1813).
Various fixes to command_line_flags (#1816, #1819, #1821).
Functions that start with operator
now get properly generated (#1817).
Thanks to all the awesome contributors that sent patches included in this release!
Released 2020/05/21.
__stdcall
(#1781).Released 2020/05/21.
Note: This release contains the same fixes and additions as 0.54.0, but without the Objective-C breaking changes
__stdcall
(#1781).Released 2020/03/10.
Released 2020/02/03.
Released 2020/02/02.
Released 2019/11/19.
newtype
enum style, much like bitfield
but without the bitwise ops (#1677).MaybeUninit
rather than mem::uninitialized()
(#1666).default-features = false
, you probably want to use the "runtime"
feature to get the same behavior as before.regex
unicode features).#[must_use]
support for libclang 9+ (#1646).BitfieldUnit
constructor to handle 64 bit wide bitfields on 32 bit (#1640).ParseCallbacks
handler for included files. (#1637).Released 2019/09/23.
Ord
and PartialOrd
implementations were fixed, which regresses bindgen in funny ways when using rustc nightly. Dot releases for a few of the previous versions of bindgen will be created with this fix. Also, a v0.51.1-oldsyn
version was uploaded without the syn update. #1627Syn and related dependencies have been updated. #1611
Switches added to allow less dependencies. In particular: It won‘t pull failure
and related dependencies by default, and there’s a default-on which-rustfmt
feature which allows to get rid of which
altogether. #1615 / #1625
fxhash
dependency was switched to rustc-hash
. #1626
Released 2019/07/26.
Improve workaround for LLVM stack overflow when evaluating value-dependent expressions. #1591
Bindgen will properly detect the layout of incomplete arrays. #1592
Bindgen will properly detect the layout of empty unions and forward declarations of unions. #1593 and #1595. Thanks @pmarks!
wchar_t
is computed. This is a breaking change since IntKind::WChar
(exposed in ParseCallbacks
) no longer needs a size
member. #1596RUSTFMT
in the environment to try to find a suitable rustfmt
binary. #1602Released 2019/07/01.
Fixed pointers to Objective C blocks #1582.
Various bindgen auto-generated types are now constructible in const fn
contexts #1571
It is possible to generate #[non_exhaustive]
enums for rust nightly targets. #1575
It is possible to avoid building clap now if you're using bindgen as a library. #1581.
Released 2019/06/25. YANKED
Various bindgen auto-generated types are now constructible in const fn
contexts #1571
It is possible to generate #[non_exhaustive]
enums for rust nightly targets. #1575
It is possible to avoid building clap now if you're using bindgen as a library. #1581.
Released 2019/05/22
void foo(int arr[2])
would be generated as arr: *mut [c_int; 2]
rather than arr: *mut c_int
. Thanks @elichai! #1564.Released 2019/05/16
#[link_name]
attributes in win32 and macos for C functions and constants where it can detect it's not needed (thanks @michaelwoerister!). #1558hashbrown
internally, and will use fxhash and std::HashMap
. This is equivalent for newer rustc
s since hashbrown
was merged in libstd, and the performance difference should be close to zero for older rustcs.Released 2019/03/27
--target
is specified. The detect_include_paths
option can be used to opt-out of this behavior.Released 2019/03/06
Released 2019/03/04
Released 2020/11/13
Released 2019/02/25
Released 2019/02/22
Released 2019/02/02
clang-sys
update for regressions #1505Released 2019/01/19
#pragma pack(n)
is now translated to #[repr(C, packed(n))]
when targeting Rust 1.33+. #537#[repr(transparent)]
instead of #[repr(C)]
when targeting Rust 1.28+. #1474#[repr(packed)]
is now properly added if the struct only contains a vtable. #1495clang-sys
should now more accurately find libclang versions when multiple of them are available. #1489https://github.com/rust-lang/rust-bindgen/compare/v0.32.2...v0.46.0
(Just a sneak peek, since a lot of stuff has changed :D)
link
, link_framework
, link_static
) have been removed. They did nothing already, see #104wchar_t
layout works properly now. #1345Released 2018/02/14
quote = "0.4"
and addition of the proc_macro2
dependency. The proc_macro2
crate depends on rustc
internal libraries, which means that CLIs which use it must be run under rustup
, which is not acceptable for bindgen
. #1248Released 2018/01/22
_Complex _Float128
. #1087bool
. #1145rustfmt
directly instead of via rustup
. #1184Released 2017/12/18
enum
s into Rust enum
s using rustified_enum
/ --rustified-enum
, properly add #[repr(C)]
to the emitted enum
. #1183Released 2017/12/08
Added support for bit-field allocation units that are larger than 64 bits wide. Note that individual bit-fields within such units are still restricted to being no wider than 64 bits. #1158
We can now generate random C header files and test that bindgen
can process them with the quickcheck
crate. Initial support landed in [#1159][] with a few more additions in follow up pull requests.
The bindgen::Builder::{constified_enum_module,{bitfield,rustified}_enum}
builder methods and their corresponding CLI flags now compare their argument to the C/C++ enum
's “canonical path”, which includes leading namespaces, rather than its “canonical name”, which does not. This is a breaking change that requires callers which target a namespaced C++ enum to call e.g. bitfield_enum("<namespace>::<enum_name>")
rather than e.g. bitfield_enum("<enum_name>")
. #1162
When a struct is packed to a smaller alignment that is still greater than one, bindgen
cannot emit Rust bindings that match the input source. Before, it would emit #[repr(packed)]
anyways, which packs to an alignment of one, but this can lead to misalignment and UB. Now, bindgen
will detect these situations and convert the struct into an opaque blob of bytes with the proper alignment. We are eagerly awaiting support for #[repr(packed(N))]
in Rust. #1136
There was a perfect storm of conditions that could cause bindgen
not to emit any bindings if spawning rustfmt
to format the bindings failed. This is now fixed. #1112
In some circumstances, bindgen
would emit type parameters twice for references to template instantiations. This is now fixed. #1113
When a C/C++ struct had a field named with a Rust keyword, and impl_debug
was enabled, the generated impl Debug for ...
blocks could reference the field by the Rust keyword name, rather than the non-keyword field name we actually end up generating. This is now fixed. #1123
There was a regression in 0.31.0 where C++ template aliases to opaque types would sometimes not treat the aliased type as opaque. This is now fixed. #1118
There was a regression in 0.31.0 that could cause bindgen
to panic when parsing nested template classes. This is now fixed. #1127
Unnamed bit-fields do not affect alignment of their struct or class in C/C++, however bindgen
interpreted them as doing so, which could generate #[repr(C)]
structs expecting to have an incorrect alignment. This is now fixed. #1076
When a zero-sized type was used in a bit-field, bindgen
could divide-by-zero. This is now fixed. #1137
When a template parameter is used in a bit-field, bindgen
would panic. This is now fixed. #1140
There was a regression in 0.31.0 where if bindgen
was given a header file that did not exist, it would panic. This is now fixed, and it will instead properly report the error. #1146
In some cases, generated bit-field getters and setters could access memory beyond self
. This is now fixed. [#954][]
Released 2017/10/27
🎉 A new bindgen
reviewer: @pepyakin 🎉 You can ask @pepyakin to review all your future pull requests with r? @pepyakin
from now on 😄
Timers for seeing which phases bindgen
is spending its time in. On the command line, use the --time-phases
flag. From a builder, use the bindgen::Builder::time_phases(true)
method. #938
You can now disable #[derive(Copy)]
for all types with --no-derive-copy
and bindgen::Builder::derive_copy(false)
. #948
We now have an overview of bindgen
's code base and architecture for newcomers in CONTRIBUTING.md
. #988
Derive PartialOrd
with the --with-derive-partialord
CLI flag or bindgen::Builder::derive_partialord(true)
builder method. #882
Derive Ord
with the --with-derive-ord
CLI flag or bindgen::Builder::derive_ord(true)
builder method. #884
When PartialEq
cannot be derived because of an array larger than Rust's array-derive limit, bindgen
can emit an impl PartialEq for ...
block. Enable this behavior with the --impl-partialeq
CLI flag or the bindgen::Builder::impl_partialeq(true)
method. #1012
When deriving PartialEq
for all types, you can now specify particular types that shouldn't derive(PartialEq)
with the --no-partialeq <regex>
CLI flag or bindgen::Builder::no_partialeq("<regex>")
builder method. #996
Specify types that should not derive Copy
with the --no-copy <regex>
CLI flag or bindgen::Builder::no_copy("<regex>")
builder method. This functionality was previously only available via comment annotations in the header sources. #1099
When deriving Hash
for all types, you can now specify particular types that shouldn't derive(Hash)
with the --no-hash <regex>
CLI flag or bindgen::Builder::no_hash("<regex>")
builder method. #1105
The bindgen
users guide now has an FAQ section! If you have any FAQ suggestions to put up there, please open a pull request. [#1020][]
Added csmith
fuzzing infrastructure. csmith
generates random C and C++ programs, we feed those into bindgen
as headers to generate bindings to, then test that the generated bindings compile and that their layout tests pass. This infrastructure landed in many small bits.
We <3 folks who help us find and fix issues via fuzzing! hint hint
Added experimental support for the thiscall
ABI when targetting Rust nightly. #1065
If the user does not explicitly pass a --target
argument for libclang
, bindgen
will insert such an argument itself. See #942, #947, and #953 for details.
C/C++ enum
s are now translated into constants by default, rather than Rust enum
s. The old behavior was a big footgun because rustc
assumes that the only values of an enum
are its variants, whereas a lot of C/C++ code uses random values as enum
s. Put these two things and it leads to undefined behavior. Translating C/C++ enum
s into Rust enum
s is still available with the --rustified-enum <regex>
CLI flag and bindgen::Builder::rustified_enum("<regex>")
builder method. #758
Generated bindings are now pretty printed with rustfmt
by default. Previously, this option existed, but was off by default because syntex
did an OK job at pretty printing the bindings. Now that we are using quote! { ... }
instead of syntex
, we lost that pretty printing, and now rely on rustfmt
. You can disable rustfmt
ing with --no-rustfmt-bindings
or bindgen::Builder::rustfmt_bindings(false)
. See #925 and #1022 for details.
bindgen::Builder::hide_type
is deprecated in favor of bindgen::Builder::blacklist_type
. #987
bindgen::Builder::whitelisted_type
is deprecated in favor of bindgen::Builder::whitelist_type
. #987
bindgen::Builder::whitelisted_function
is deprecated in favor of bindgen::Builder::whitelist_function
. #985
bindgen::Builder::whitelisted_var
is deprecated in favor of bindgen::Builder::whitelist_var
. #989
Removed the dependency on (unmaintained) syntex
, and build times are cut in half!
Before:
$ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 98.75 secs
After:
$ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs
The BindgenOptions
type is no longer public. It had been deprecated in previous releases. Use bindgen::Builder
instead. #1000
Under certain conditions, a globally scoped enum
could end up with bindings in the wrong namespace module. #888
Blacklisted types were incorrectly assumed to always be Copy
able (and assumed to implement other traits as well). bindgen
is now conservatively pessimistic about the traits that blacklisted types implement. #944
When bitfields have a ridiculously large number of bits (for example, unsigned : 632;
) then bindgen
was incorrectly deriving traits that couldn't be derived, resulting in errors when compiling the bindings, and was also generating struct
s with an incorrect layout. Both issues have been fixed. #982
_
is a valid identifier in some C++ contexts, but can't be referenced in Rust, as it is the “throwaway identifier” (a term I just made up, if you use it now, then you owe me money). bindgen
will now translate _
into __
so that it can be used on the Rust side. #1008
Nested class definitions were sometimes being emitted in the wrong namespace module in the generated bindings. #1048
bindgen
was mis-handling union
s that contained bitfield members. This has been fixed. #744
Unsigned constants that were greater than u32::MAX
were being mis-translated by bindgen
. This is now fixed. #1040
When given a directory as an input file, or a file to which we don't have read permissions, then bindgen
will print a more useful error message now. #1029
bindgen
previously attempted to derive Hash
for structures with flexibly-sized array members, but knowing how many elements exist in such arrays requires program-specific knowledge that bindgen
cannot have. #1094
Released 2017/08/28
bindgen::Builder::default() .rust_target(bindgen::RustTarget::Stable_1_19) // or `.rust_target(bindgen::RustTarget::Nightly)` to use unstable features
or
$ bindgen --rust-target 1.19 # or `--rust-target nightly` to use unstable features
Started adding derive(Copy)
for large arrays of Copy
things, even when the array is too large to derive(Clone)
because Rust doesn't implement Clone
for arrays of length greater than 32. #874
bindgen
can now determine which types are hashable and add derive(Hash)
to those types that support it. This is disabled by default, but can be enabled via bindgen::Builder::derive_hash
or --with-derive-hash
. #876
bindgen
can now generate impl Debug for Blah
trait implementations for types that contain non-Debug
types, and therefore cannot derive(Debug)
. This behavior can be enabled with bindgen::Builder::impl_debug
and --impl-debug
. #875
bindgen
can now invoke rustfmt
on the generated bindings. The bindings have historically been fairly pretty printed, but sometimes this is not the case, especially with the new impl Debug for Blah
feature. Have bindgen
run rustfmt
with bindgen::Builder::rustfmt_bindings
and --rustfmt-bindings
, and use non-default rustfmt
configuration files with bindgen::Builder::rustfmt_configuration_file
and --rustfmt-configuration-file
. #900
bindgen
can now determine which types can be compared with ==
and add derive(PartialEq)
to those types that support it. This is disabled by default, but can be enabled via bindgen::Builder::derive_partialeq
or --with-derive-partialeq
. #878
Additionally, bindgen
can also add derive(Eq)
to those types which we determined we could derive(PartialEq)
and do not transitively contain any floats. Enable this behavior with bindgen::Builder::derive_eq
or --with-derive-eq
. #880
Started emitting Rust union
s when targeting stable Rust >= 1.19, not just unstable nightly Rust. #832
Emitted layout #[test]
s no longer contain internal IDs for template instantiations including pointers and arrays. This should make generated bindings more stable across updates to unrelated parts of the input headers. #871
Determining whether a type can derive Copy
or not was ported from an ad-hoc algorithm to our fix-point framework. #766
Determining whether a type has a destructor or not was also ported from an ad-hoc algorithm to our fix-point framework. #927
bindgen::Builder::unstable_rust
/--unstable-rust
is deprecated, in favor of targeting explicit Rust versions with bindgen::Builder::rust_target
/--rust-target
instead. #832Fixed a regression in the derive(Default)
analysis that resulted in some opaque types deriving Default
when they shouldn't have. #889
Fixed a regression where template instantiation layout #[test]
s were being generated with invalid Rust identifiers. #906
Released 2017/07/31
“Constified enum modules” translating C/C++ enum
s into constants within a module for namespacing, rather than mangling the name of the generated constants.
For example, it turns this:
// bindgen-flags: --constified-enum-module PetKind enum PetKind { Doggo, Kitty, Hamster }; struct Pet { PetKind kind; char* noise; };
Into this:
/* automatically generated by rust-bindgen */ pub mod PetKind { pub type Type = ::std::os::raw::c_uint; pub const Doggo: Type = 0; pub const Kitty: Type = 1; pub const Hamster: Type = 2; } #[repr(C)] #[derive(Debug, Copy)] pub struct Pet { pub kind: PetKind::Type, pub noise: *mut ::std::os::raw::c_char, }
The default translation strategy for enum
s will generate constants with names like PetKind_Hamster
instead.
Use bindgen::Builder::constified_enum_module
or --constified-enum-module
.
You can now mark particular template instantiations as “opaque”, so that bindgen
emits a blob of bytes with the correct size and alignment rather than creating generic Rust types. This is useful as a workaround for when a template has a specialization for the given type arguments, which bindgen
does not yet support. Previously, it was all of a templates' instantiations would be opaque or none of them would be. Use bindgen::Builder::opaque_type("SomeTemplate<Foo, Bar>")
or --opaque-type "SomeTemplate<Foo, Bar>"
.
Added the ability to preprocess and dump the input headers given to bindgen
to a file. This should make creating reproducible, system independent, standalone test cases much easier! Bring on the new issues! Use bindgen::Builder::dump_preprocessed_input
or --dump-preprocessed-input
.
We now use a fix-point analysis to determine whether any given type can derive Debug
, or whether it has an explicit virtual table pointer. Previously we were using an ad-hoc algorithm that had at various times suffered from things like going into infinite loops when coming across cycles. Hopefully those kinds of bugs are a thing of the past! #767 #765
bindgen
repository has moved under the rust-lang-nursery
umbrella! The new repository URL is https://github.com/rust-lang-nursery/rust-bindgen 🎉No longer generating layout tests for template instantiations using type arguments that we didn't generate bindings for (which then caused compilation errors). #679
Fixed function name mangling when cross compiling bindings for iOS. #776
Don‘t include parent inline namespace
s’ names in types' names. Names of types from some STLs were showing up like std___cxx11_basic_string
when they should have been std_basic_string
. #789
Fixed a bug where we wouldn‘t generate type definitions for some types referenced by an opaque type’s methods, causing compilation errors. #807
Fixed function name mangling issues for win32 targets. #819
Fixed a bug where bindgen
was generating a generic type alias that didn't use its type parameter, which is illegal Rust code and caused compilation errors. #820
The generated size, alignment, and field offset unit tests now have stable names rather than sometimes including an internal identifier which is inherently unstable. This was causing unnecessary diffs when folks were checking in new versions of bindings into their VCS. #394
Fixed a bug where we would try and derive(Debug, Default)
on structs that had padding like [u8; 33]
, which is larger than the largest array length for which Rust will derive traits. This would cause compilation errors when compiling the emitted bindings. #648