- Unreleased
- 0.72.0 (2025-06-08)
- v0.71.1 (2024-12-09)
- 0.71.0 (2024-12-06)
- 0.70.1 (2024-08-20)
- 0.70.0 (2024-08-16)
- 0.69.4 (2024-02-04)
- 0.69.3 (2024-02-04)
- 0.69.2 (2024-01-13)
- 0.69.1 (2023-11-02)
- 0.69.0 (2023-11-01)
- 0.68.1
- 0.68.0
- 0.67.0
- 0.66.1
- 0.66.0
- 0.65.1
- 0.65.0
- 0.64.0
- 0.63.0
- 0.62.0
- 0.61.0
- 0.60.1
- 0.60.0
- 0.59.2
- 0.59.1
- 0.59.0
- 0.58.1
- 0.58.0
- 0.57.0
- 0.56.0
- 0.55.1
- 0.55.0
- 0.54.1
- 0.54.0
- 0.53.3
- 0.53.2
- 0.53.1
- 0.53.0
- 0.52.0
- 0.51.1
- 0.51.0
- 0.50.0
- 0.49.3
- 0.49.2
- 0.49.1
- 0.49.0
- 0.48.1
- 0.48.0
- 0.47.4
- 0.47.3
- 0.47.2
- 0.47.1
- 0.47.0
- 0.33.1 .. 0.46.0
- 0.33.1
- 0.33.0
- 0.32.2
- 0.32.1
- 0.32.0
- 0.31.0
- 0.30.0
- 0.29.0
- Removed support for generating code for rustc versions < 1.51.
- Typo in code for
--rustified-non-exhaustive-enums(#3266)
- Report enums in ParseCallbacks.
- Refactor item_name method to use ItemInfo struct.
- Add callback to modify contents of macro
- Discovery callbacks for functions and methods.
- Options to generate uncallable C++ functions.
- Provide option to get real virtual fn receiver.
- Generate bindings compatible with current rustc version by default.
- Remove unused which-rustfmt feature
- Remove warning for opaque forward declarations
- More sophisticated handling of the triple in rust_to_clang_target
- Rename *-apple-ios-sim to ...simulator
- Fix OpenCL vectors that use "ext_vector_type".
- Fix union layout when it contains 0 sized array.
- Avoid crashing on variadic unions without layout information.
- Distinguish char16_t.
- Fix bugs in --clang-macro-fallback
- Add missed unsafe in the raw_set_bit function
- Use link_name for dynamic library loading
- Add "gen" to list of rust keywords in 'rust_mangle'
- Use appropriate
rustfmt --format ...param
- Fix
--versionand--generate-shell-completions(#3040)
- Add the
ParseCallbacks::new_item_foundcallback to expose the original and final name of structs, unions and enums (#2658). - Add the
field_type_namefield toFieldInfoto expose the name of the type of a field (#2863) - Add support for custom attributes with the
--with-attribute-customflag (#2866) - Allow setting
--rust-targetto any Rust version supported by bindgen (#2993) - Use c-string literals if the
--generate-cstrflag is used for Rust targets after 1.77 under the 2021 edition (#2996) - Add the
--rust-editionflag which allows to select which Rust edition to target. (#3002, #3013) - Use
unsafe externinstead ofexternin blocks for any Rust target after 1.82. (#3015)
- The
--wrap-static-fnsrelated options no longer require the experimental feature or flag (#2928) - Use the
Displayimplementation instead of theDebugone forBindgenErrorinbindgen-cli(#3005)
- Dropped support for any Clang versions strictly lower than 9.0 (#2932)
- Dropped support for any Rust version strictly lower than 1.33 (#2993)
- Represent opaque types in a FFI-safe way (#2880)
- Use the underlying type of any atomic type instead of panicking (#2920)
- Use the right characters for newlines on windows (#2923)
- Inlined namespaces are properly recognized now (#2950)
- Unsafe calls to
libloadingare now wrapped inunsafeblocks when using dynamic loading (#2961) - The
ParseCallbacks::field_visibilitycallback is now called for newtypes as well (#2967) - Gate the use of the
addr_ofandaddr_of_mutmacros under the 1.51 rust version (#2988)
- Fix regression where the
constlayout tests were triggering theunnecessary_operationandidentity_opclippy warnings.
- Add target mappings for riscv64imac and riscv32imafc.
- Add a complex macro fallback API (#2779).
- Add option to use DST structs for flexible arrays (--flexarray-dst, #2772).
- Add option to dynamically load variables (#2812).
- Add option in CLI to use rustified non-exhaustive enums (--rustified-non-exhaustive-enum, #2847).
- Add field_type_name to FieldInfo.
- Remove which and lazy-static dependencies (#2809, #2817).
- Generate compile-time layout tests (#2787).
- Print
bindgen-clierrors to stderr instead of stdout (#2840)
- Fix
--formatter=prettypleasenot working inbindgen-cliby addingprettypleasefeature and enabling it by default forbindgen-cli(#2789) . - Fix
--allowlist-itemso anonymous enums are no longer ignored (#2827). - Use clang_getFileLocation instead of clang_getSpellingLocation to fix clang-trunk (#2824).
- Fix generated constants:
f64::INFINITY,f64::NEG_ INFINITY,f64::NAN(#2854).
- Update
tempfileandrustixdue to GHSA-c827-hfw6-qwvm.
- Allow older itertools. (#2745)
- Added blocklist_var (#2731)
- Stabilized thiscall_abi (#2661)
- Use CR consistently on windows (#2698)
- Replaced peeking_take_while by itertools (#2724)
- Try to avoid repr(packed) for explicitly aligned types when not needed (#2734)
- Improved destructor handling on Windows (#2663)
- Support Float16 (#2667)
- Fix alignment contribution from bitfields (#2680)
- Fixed msrv build.
- Updated shlex dependency (RUSTSEC-2024-0006)
- Fixed generation of extern "C" blocks with llvm 18+. See #2689.
- Allow to run
bindgen -vwithout an input header argument.
- Added the
ParseCallbacks::header_filecallback which runs on every filename passed toBuilder::header. - Added the
CargoCallbacks::newconstructor which emits a cargo-rerun line for every input header file by default. - Added the
CargoCallbacks::rerun_on_header_filesmethod to configure whether a cargo-rerun line should be emitted for every input header file.
- The
--wrap-static-fnsfeature was updated so function types that has no argument usevoidas its sole argument. CargoCallbacksis no longer a unit-like struct and theCargoCallbacksconstant was added to mitigate the breaking nature of this change. This constant has been marked as deprecated and users will have to use the newCargoCallbacks::newmethod in the future.
- Allow compiling
bindgen-cliwith a static libclang. - Emit an opaque integer type for pointer types that don't have the same size as the target's pointer size.
- Avoid escaping Objective-C method names unless they are
Self,self,crateorsuper.
- Fixed errors on the windows artifact build process.
- The
systemABI is now supported as an option for the--override-abiflag. - The
allowlist_itemmethod and the--allowlist-itemflag have been included to filter items regardless or their kind. - Include installers as release artifacts on Github.
- The
Cloneimplementation for_BindgenUnionFieldhas been changed to pass theincorrect_clone_impl_on_copy_typeClippy lint. - The
c_unwindABI 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). - Formatting changes when using prettyplease as a formatter due to a new prettyplease version.
- Avoid generating invalid
CStrconstants when using the--generate-cstroption.
- The
extra_assertandextra_assert_eqmacros are no longer exported.
- Bindgen no longer panics when parsing an objective-C header that includes a
Rust keyword that cannot be a raw identifier, such as:
self,crate,superorSelf.
This version was skipped due to some problems on the release workflow.
- Revert source order sorting (#2543) due to correctness regressions #2558.
- Added the
--generate-cstrCLI flag to generate string constants as&CStrinstead of&[u8]. (Requires Rust 1.59 or higher.) - Added the
--generate-shell-completionsCLI flag to generate completions for different shells. - The
--wrap-static-fnsoption can now wrapva_listfunctions as variadic functions with the experimentalParseCallbacks::wrap_as_variadic_fnmethod. - Add target mappings for riscv32imc and riscv32imac.
- Add the
ParseCallbacks::field_visibilitymethod to modify field visibility.
- Non-UTF-8 string constants are now generated as references (
&[u8; SIZE]) instead of arrays ([u8; SIZE]) to match UTF-8 strings. - Wrappers for static functions that return
voidno longer contain areturnstatement and only call the static function instead. - The
--wrap-static-fnsoption no longer emits wrappers for static variadic functions. - Depfiles generated with
--depfileorBuilder::depfilewill now properly generate module names and paths that include spaces by escaping them. To make the escaping clear and consistent, backslashes are also escaped. - Updated
bitflagsdependency to 2.2.1. This changes the API ofCodegenConfig. - Prettyplease formatting is gated by an optional, enabled by default Cargo
feature when depending on
bindgenas a library. - Items are now parsed in the order they appear in source files. This may result in
auto-generated
_bindgen_*names having a different index. - Use default visibility for padding fields: Previously, padding fields were always public. Now, they follow the default visibility for the type they are in.
- Compute visibility of bitfield unit based on actual field visibility: A bitfield unit field and its related functions now have their visibility determined based on the most private between the default visibility and the actual visibility of the bitfields within the unit.
-
Remove redundant Cargo features, which were all implicit:
- bindgen-cli:
env_loggerandlogremoved in favor oflogging - bindgen (lib):
logremoved in favor ofloggingwhichremoved in favor ofwhich-loggingannotate-snippetsremoved in favor ofexperimental
- bindgen-cli:
-
Prettyplease is available as a
Formattervariant now.
- The
Builder::rustfmt_bindingsmethod was added back and tagged as deprecated instead of being removed. - Broken documentation links were fixed.
- Added the
Builder::default_visibilitymethod and the--default-visibilityflag to set the default visibility of fields. (#2338) - Added the
--formatterCLI flag with the valuesnone,rustfmtandprettypleaseto select which tool will be used to format the bindings. The default value isrustfmt. (#2453) - Added the
Builder::formattermethod and theFormattertype to select which tool will be used to format the bindings. (#2453) - Added the
Builder::emit_diagnosticsmethod and the--emit-diagnosticsflag to enable emission of diagnostic messages under theexperimentalfeature. (#2436) - Added support for the
"efiapi"calling convention (#2490). - Added the
ParseCallbacks::read_env_varmethod which runs everytimebindgenreads and environment variable. (#2400) - Added the
ParseCallbacks::generated_link_name_overridemethod which allow overriding the link name of items. (#2425) - Add support for C
enums when generating code while using the--wrap-static-fnsfeature. (#2415)
- Static functions with no arguments use
voidas their single argument instead of having no arguments when the--wrap-static-fnsflag is used. (#2443) - The source file generated when the
--wrap-static-fnsflag is enabled now contains#includedirectives with all the input headers and all the source code added with theheader_contentsmethod. (#2447) - The source file generated when the
--wrap-static-fnsflag no longer usesasmlabeling and the link name of static wrapper functions is allowed to be mangled. (#2448) - The documentation of the generated
typealiases now matches the comments of theirtypedefcounterparts instead of using the comments of the aliased types. (#2463) - The
Builder::rustfmt_bindingsmethods and the--no-rustfmt-bindingsflag are now deprecated in favor of the formatter API. (#2453)
- The following deprecated flags were removed:
--use-msvc-mangling,--rustfmt-bindingsand--size_t-is-usize. (#2408) - The
Bindings::emit_warningsandBindings::warningsmethods were removed in favor of--emit-diagnostics. (#2436) - Bindgen no longer generates C string constants that cannot be represented as byte slices. (#2487)
- Added a new set of flags
--with-derive-custom,--with-derive-custom-struct,--with-derive-custom-enumand--with-derive-custom-enumto add custom derives from the CLI. - Added the
--experimentalflag onbindgen-cliand theexperimentalfeature onbindgento gate experimental features whose implementation is incomplete or are prone to change in a non-backwards compatible manner. - Added a new set of flags and their equivalent builder methods
--wrap-static-fns,--wrap-static-fns-suffixand--wrap-static-fns-pathto generate C function wrappers forstaticorstatic inlinefunctions. This feature is experimental.
- Fixed name collisions when having a C
enumand atypedefwith the same name. - The
ParseCallbacks::generated_name_overridemethod now receivesItemInfo<'_>as argument instead of a&str. - Updated the
clang-syscrate version to 1.4.0 to support clang 15. - The return type is now omitted in signatures of functions returning
void. - Updated the
clapdependency forbindgen-clito 4. - Rewrote the
bindgen-cliargument parser which could introduce unexpected behavior changes. - The
ParseCallbacks::add_derivesmethod now receivesDeriveInfo<'_>as argument instead of a&str. This type also includes the kind of target type.
- new feature:
process_commentsmethod to theParseCallbackstrait to handle source code comments.
- Only wrap unsafe operations in unsafe blocks if the
--wrap_unsafe_opsoption is enabled. - Replace the
name: &strargument forParseCallbacks::add_derivesbyinfo: DeriveInfo. - All the rust targets equal or lower than
1.30are 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.
- The following deprecated methods and their equivalent CLI arguments were
removed:
whitelist_recursively,hide_type,blacklist_type,blacklist_function,blacklist_item,whitelisted_type,whitelist_type,whitelist_function,whitelisted_function,whitelist_var,whitelisted_var,unstable_rust.
- new feature:
--override-abiflag to override the ABI used by functions matching a regular expression. - new feature: allow using the
C-unwindABI in--override-abion nightly rust.
- Regex inputs are sanitized so alternation (
a|b) is handled correctly but wildcard patterns (*) are now considered invalid. The.*pattern can be used as a replacement. - the
ParseCallbackstrait does not require to implementUnwindSafe. - the
Builder::parse_callbacksmethod no longer overwrites previously added callbacks and composes them in a last-to-first manner. - any generated rust code containing unsafe operations inside unsafe functions is wrapped in unsafe blocks now.
- Various issues with upcoming clang/libclang versions have been fixed.
Released 2022/10/16
- new feature:
--sort-semanticallyflag to sort the output in a predefined manner (#1743). - new feature:
Bindgen::emit_warningsmethod to emit warnings to stderr in build scripts. - new feature:
--newtype-global-enumflag to generate enum variants as global constants. - new feature:
--default-non-copy-union-styleflag to set the default style of code used to generate unions with non-Copymembers. - new feature:
--bindgen-wrapper-unionflag to mark any union that matches a regex and has a non-Copy member to use a bindgen-generated wrapper for its fields. - new feature:
--manually-drop-unionflag to mark any union that matches a regex and has a non-Copymember to useManuallyDrop. - new feature:
--merge-extern-blocksflag to merge severalexternblocks that have the same ABI. - new feature:
--no-size_t-is-usizeflag to not bindsize_tasusize. - new feature:
BuilderimplementsClone.
- clap and regex have been updated, new msrv is 1.57.
- The
--enable-function-attribute-detectionflag is also used to detect diverging functions so the generated bindings use!as the return type. - The
--size_t-is-usizeflag is enabled by default. - Unused type aliases for
<stdint.h>types are no longer emitted. - The
blocklistoptions now can be used to block objective-C methods. - The
core::ffimodule is used the sized raw integer types instead ofstd::os::rawif the Rust target version is1.64or higher and the--use-coreflag is enabled. - The
bindgenCLI utility must be installed usingcargo install bindgen-clinow. - Using
bindgenas a library no longer pulls clap and any other CLI related dependencies.
- Const correctness of incomplete arrays has been fixed. (#2301)
- C++ inline namespaces don't panic. (#2294)
Released 2022/06/06
- Fixed stack overflow in generated tests for structs with many fields (#2219).
Released 2022/06/05
- Objective-C structs now derive
DebugandCopyto support C and Objective-C structs. (#2176) - Allow fully-qualified derives. (#2156)
- Bindings generation now returns a more suitable error (#2125)
--version --verbosenow prints clang version (#2140).- Experimental vtable generation (#2145).
- Added an
--allowlist-fileoption (#2122). - Support for vectorcall ABI (#2177).
- Fixed lifetimes with Objective-C trait templates. (#2176)
- Fixed objc imports for non-
#[macro_use]use. (#2176) - Handle differences between clang and rustc targets for RISCV (#2137).
BINDGEN_EXTRA_CLANG_ARGSis respected on the CLI now (#1723).- Use common type alias for anonymous enums in consts mode (#2191)
- Look for
#[must_use]in typedefs (#2206). - Fixed derive on packed structs (#2083).
- Fixed warnings on layout tests (#2203).
- cexpr, clap, and nom have been updated, new msrv is 1.54.
- Support for ancient libclang versions has been removed.
Released 2021/11/26
- cexpr+env_logger bump.
- Various fixes for C++ crashes / hangs.
- Enums now respect annotations and derives properly in more cases.
- Some more APIs (blocklist-file, etc).
- 'static lifetime is elided when appropriate.
Released 2021/07/26
- Fixed incorrect bitfield constructors generated for very large bitfields (#2082).
Released 2021/07/20
- Support emitting Makefile-syntax depfiles (#2026)
- Add a C naming option (#2045)
- Allow explicit padding (#2060)
- Add custom derives callback (#2059)
- Let Rust derive everything but Default for large arrays in 1.47 and later (#2070).
- Constants now have docstrings (#2027)
- Don't generate bindings for deleted member functions. (#2044)
- Zero out padding in custom Default trait implementations (#2051)
- Identify forward declarations in params. (#2052)
- Add env var EXTRA_CLANG_ARGS_. (#2031)
- cexpr and nom have been updated, new msrv is 1.44 (#2073).
Released 2021/04/06
- Re-introduced unintentionally removed
bindgen::Builder::whitelist_recursively(deprecated in favor ofbindgen::Builder::allowlist_recursively). [#2022][]
Released 2021/04/03
- Add option to translate enum integer types to native Rust integer types. [#2004][]
- Add callback to check derives for blocklisted types. [#2007][]
- Add a flag to ensure all symbols are resolved when a library is loaded. [#2013][]
- Add from_library for generated dynamic library structs [#2011][].
- Track union layout more accurately. Fixes an AArch64 bug and makes the bindings more portable where unions could return garbage data (#1984)
- Use original name when checking allowlist for anonymous enum variants. [#2006][]
-
bindgen::Builder::whitelist_typeis deprecated in favor ofbindgen::Builder::allowlist_type. [#1812][] -
bindgen::Builder::whitelist_functionis deprecated in favor ofbindgen::Builder::allowlist_function. [#1812][] -
bindgen::Builder::whitelist_varis deprecated in favor ofbindgen::Builder::allowlist_var. [#1812][] -
--whitelist-typeis deprecated in favor of--allowlist-type. [#1812][] -
--whitelist-functionis deprecated in favor of--allowlist-function. [#1812][] -
--whitelist-varis deprecated in favor of--allowlist-var. [#1812][] -
bindgen::Builder::blacklist_typeis deprecated in favor ofbindgen::Builder::blocklist_type. [#1812][] -
bindgen::Builder::blacklist_functionis deprecated in favor ofbindgen::Builder::blocklist_function. [#1812][] -
bindgen::Builder::blacklist_itemis deprecated in favor ofbindgen::Builder::blocklist_item. [#1812][] -
--blacklist-typeis deprecated in favor of--blocklist-type. [#1812][] -
--blacklist-functionis deprecated in favor of--blocklist-function. [#1812][] -
--blacklist-itemis deprecated in favor of--blocklist-item. [#1812][]
Released 2021/02/01
- Expose module-raw-lines to the CLI (#1936)
- Added an option to fit macro constants to smaller types (#1945)
- Add an option to respect C++ access specifiers on fields (#1968)
- Improved C++ auto-detection (#1933)
- Fixed layout of bitfields in some edge cases (#1950)
- Escape the dyn keyword properly (#1951)
- Use absolute paths for unsaved files passed to clang (#1857).
Released 2020/11/26
- Objective-c bindings generate
From<ChildClass> for ParentClassas well asTryFrom<ParentClass> for ChildClass(#1883). - Experimental dynamic library support via
dynamic_library_name(#1846). - Option to disable deriving
Defaulton a per-struct basis (#1930).
- Objective-c bindings borrow self rather than take ownership (#1883).
- Templates and enums now correctly use the same naming scheme as other types (#1891).
- Constructors in wasm32 now return a value. (#1877).
- Fixed objective-c protocol impl blocks for parent classes's protocols (#1883).
Released 2020/08/24.
- Fixed a regression where anonymous enums referenced by members or such won't generate valid Rust code. (#1882).
Released 2020/08/23.
- Support for libclang 3.8 has been removed (#1830).
-
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
operatornow get properly generated (#1817).
Thanks to all the awesome contributors that sent patches included in this release!
Released 2020/05/21.
- New command line flag to allow disabling untagged unions (#1789).
- Various documentation improvements (#1764, #1751, #1757).
- Better Objective-C support (#1722, #1750).
- Rust method wrappers are not emitted for blacklisted functions (#1775).
- Fixed function signatures in some edge cases involving Objective-C or
__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
- New command line flag to allow disabling untagged unions (#1789).
- Rust method wrappers are not emitted for blacklisted functions (#1775).
- Fixed function signatures in some edge cases involving Objective-C or
__stdcall(#1781).
Released 2020/03/10.
- clang-sys and cexpr have been updated (#1741 and #1744).
- Runtime of some commands has been improved (#1737)
- Some error messages have been improved (#1734).
Released 2020/02/03.
- Opt-in to convert size_t to usize again (#1720).
Released 2020/02/02.
- Support for wasm_import_module. (#1691).
- non_exhaustive feature is now stable (#1698).
- Various objective-C improvements (#1702).
- Removed size_t to usize conversion rule (#1688).
- Various unneeded padding fields shouldn't be generated anymore (#1710).
- Bitfields on packed structs should generate correct layout (#1717).
- Too large bitfield blocks now generate compiling code (#1719).
Released 2019/11/19.
- Added
newtypeenum style, much likebitfieldbut without the bitwise ops (#1677). - Added support for
MaybeUninitrather thanmem::uninitialized()(#1666). - Allowed static linking (#1620) behind a feature. Note that if you're using
default-features = false, you probably want to use the"runtime"feature to get the same behavior as before.
- Use c_void from core when --use-core is specified and available (#1634).
- Various dependencies and features are non-default now (like
regexunicode features).
- Fixed crash when unknown keywords are used before a namespace (#1678).
- Do not generate implementation for clone for flexible array members (#1664).
- Fixed
#[must_use]support for libclang 9+ (#1646). - Fixed
BitfieldUnitconstructor to handle 64 bit wide bitfields on 32 bit (#1640). - Added a
ParseCallbackshandler for included files. (#1637).
Released 2019/09/23.
- Mismatched
OrdandPartialOrdimplementations 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, av0.51.1-oldsynversion was uploaded without the syn update. #1627
-
Syn and related dependencies have been updated. #1611
-
Switches added to allow less dependencies. In particular: It won't pull
failureand related dependencies by default, and there's a default-onwhich-rustfmtfeature which allows to get rid ofwhichaltogether. #1615 / #1625 -
fxhashdependency was switched torustc-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!
- Refactored the way layout of
wchar_tis computed. This is a breaking change sinceIntKind::WChar(exposed inParseCallbacks) no longer needs asizemember. #1596
- Bindgen now reads
RUSTFMTin the environment to try to find a suitablerustfmtbinary. #1602
Released 2019/07/01.
-
Fixed pointers to Objective C blocks #1582.
-
Various bindgen auto-generated types are now constructible in
const fncontexts #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 fncontexts #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
- Bindgen now has an option to generate array arguments as pointer to the array,
not to the element (so
void foo(int arr[2])would be generated asarr: *mut [c_int; 2]rather thanarr: *mut c_int. Thanks @elichai! #1564.
Released 2019/05/16
- Bindgen will not emit
#[link_name]attributes in win32 and macos for C functions and constants where it can detect it's not needed (thanks @michaelwoerister!). #1558
- Bindgen will no longer use
hashbrowninternally, and will use fxhash andstd::HashMap. This is equivalent for newerrustcs sincehashbrownwas merged in libstd, and the performance difference should be close to zero for older rustcs.
Released 2019/03/27
- BINDGEN_EXTRA_CLANG_ARGS environment variable was added (thanks @jhwgh1968!). #1537
- Bindgen will properly name parameters inside nested function pointer declarations (thanks @flowbish!). #1535
- Derive code was greatly improved by @jethrogb. #1540
- Derive analysis now handles trivial types more gracefully. #1492
- clang-sys was updated by @eclipseo. [#1539][]
- bindgen should now get include paths correctly even when
--targetis specified. Thedetect_include_pathsoption can be used to opt-out of this behavior.
Released 2019/03/06
- Bindgen will properly lay out types that use reference members. #1531
Released 2019/03/04
- Default rust target was changed to 1.33, which means that bindgen can get much more often the layout of structs right. #1529
- Bindgen will output repr(align) just when needed for unions. #1498
Released 2020/11/13
- Backported BINDGEN_EXTRA_CLANG_ARGS support per request (#1910).
Released 2019/02/25
- Allowed to build with which 1.0.
Released 2019/02/22
- @flowbish fixed code generation for nested function prototypes. #1508
- Some complex C++ constructs no longer panic on code generation #1513
- Implicit template parameters are now appended to base classes #1515
- @flier fixed single-argument block pointers #1519
- Bindgen won't panic when parsing an undeduced auto type #1525
Released 2019/02/02
- @luser improved the error message when rustfmt cannot be found #1501
- Reverted
clang-sysupdate for regressions #1505
Released 2019/01/19
#pragma pack(n)is now translated to#[repr(C, packed(n))]when targeting Rust 1.33+. #537
- Bitfield enums now use
#[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. #1495
clang-sysshould now more accurately find libclang versions when multiple of them are available. #1489
https://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)
- APIs to add lines to specific rust modules / C++ namespaces exist now. #1307
- The link options (
link,link_framework,link_static) have been removed. They did nothing already, see #104
- Associated constants are used now for bitfield enums when available. #1166
- New versions of a bunch of dependencies (syn / quote / etc.).
- Better target information from clang to properly generate types when cross-compiling #1289.
- Bitfields now work properly on big-endian machines. #1340
wchar_tlayout works properly now. #1345
- Functions can be blacklisted now. #1364
- ... Lot's more!
Released 2018/02/14
- Reverted the dependency update to
quote = "0.4"and addition of theproc_macro2dependency. Theproc_macro2crate depends onrustcinternal libraries, which means that CLIs which use it must be run underrustup, which is not acceptable forbindgen. #1248
Released 2018/01/22
- Avoid symbol generation for pure virtual functions. #1197
- Handling of
_Complex _Float128. #1087 - Regression on code generation for variadic functions. #1216
- Enum code generation generates conflicting repr hint warning. #1224
- Constified code generation for enums with an explicit type of
bool. #1145 - Bindgen will now call
rustfmtdirectly instead of viarustup. #1184
Released 2017/12/18
- When translating C/C++
enums into Rustenums usingrustified_enum/--rustified-enum, properly add#[repr(C)]to the emittedenum. #1183
Released 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
bindgencan process them with thequickcheckcrate. 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,
bindgencannot 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,bindgenwill 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
bindgennot to emit any bindings if spawningrustfmtto format the bindings failed. This is now fixed. #1112 -
In some circumstances,
bindgenwould 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_debugwas enabled, the generatedimpl 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
bindgento 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
bindgeninterpreted 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,
bindgencould divide-by-zero. This is now fixed. #1137 -
When a template parameter is used in a bit-field,
bindgenwould panic. This is now fixed. #1140 -
There was a regression in 0.31.0 where if
bindgenwas 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
bindgenreviewer: @pepyakin 🎉 You can ask @pepyakin to review all your future pull requests withr? @pepyakinfrom now on 😄 -
Timers for seeing which phases
bindgenis spending its time in. On the command line, use the--time-phasesflag. From a builder, use thebindgen::Builder::time_phases(true)method. #938 -
You can now disable
#[derive(Copy)]for all types with--no-derive-copyandbindgen::Builder::derive_copy(false). #948 -
We now have an overview of
bindgen's code base and architecture for newcomers inCONTRIBUTING.md. #988 -
Derive
PartialOrdwith the--with-derive-partialordCLI flag orbindgen::Builder::derive_partialord(true)builder method. #882 -
Derive
Ordwith the--with-derive-ordCLI flag orbindgen::Builder::derive_ord(true)builder method. #884 -
When
PartialEqcannot be derived because of an array larger than Rust's array-derive limit,bindgencan emit animpl PartialEq for ...block. Enable this behavior with the--impl-partialeqCLI flag or thebindgen::Builder::impl_partialeq(true)method. #1012 -
When deriving
PartialEqfor all types, you can now specify particular types that shouldn'tderive(PartialEq)with the--no-partialeq <regex>CLI flag orbindgen::Builder::no_partialeq("<regex>")builder method. #996 -
Specify types that should not derive
Copywith the--no-copy <regex>CLI flag orbindgen::Builder::no_copy("<regex>")builder method. This functionality was previously only available via comment annotations in the header sources. #1099 -
When deriving
Hashfor all types, you can now specify particular types that shouldn'tderive(Hash)with the--no-hash <regex>CLI flag orbindgen::Builder::no_hash("<regex>")builder method. #1105 -
The
bindgenusers guide now has an FAQ section! If you have any FAQ suggestions to put up there, please open a pull request. [#1020][] -
Added
csmithfuzzing infrastructure.csmithgenerates random C and C++ programs, we feed those intobindgenas 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
thiscallABI when targeting Rust nightly. #1065
-
If the user does not explicitly pass a
--targetargument forlibclang,bindgenwill insert such an argument itself. See #942, #947, and #953 for details. -
C/C++
enums are now translated into constants by default, rather than Rustenums. The old behavior was a big footgun becauserustcassumes that the only values of anenumare its variants, whereas a lot of C/C++ code uses random values asenums. Put these two things and it leads to undefined behavior. Translating C/C++enums into Rustenums is still available with the--rustified-enum <regex>CLI flag andbindgen::Builder::rustified_enum("<regex>")builder method. #758 -
Generated bindings are now pretty printed with
rustfmtby default. Previously, this option existed, but was off by default becausesyntexdid an OK job at pretty printing the bindings. Now that we are usingquote! { ... }instead ofsyntex, we lost that pretty printing, and now rely onrustfmt. You can disablerustfmting with--no-rustfmt-bindingsorbindgen::Builder::rustfmt_bindings(false). See #925 and #1022 for details.
-
bindgen::Builder::hide_typeis deprecated in favor ofbindgen::Builder::blacklist_type. #987 -
bindgen::Builder::whitelisted_typeis deprecated in favor ofbindgen::Builder::whitelist_type. #987 -
bindgen::Builder::whitelisted_functionis deprecated in favor ofbindgen::Builder::whitelist_function. #985 -
bindgen::Builder::whitelisted_varis deprecated in favor ofbindgen::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 secsAfter:
$ cargo clean; cargo build <snip> Finished dev [unoptimized + debuginfo] target(s) in 46.26 secs -
The
BindgenOptionstype is no longer public. It had been deprecated in previous releases. Usebindgen::Builderinstead. #1000
-
Under certain conditions, a globally scoped
enumcould end up with bindings in the wrong namespace module. #888 -
Blacklisted types were incorrectly assumed to always be
Copyable (and assumed to implement other traits as well).bindgenis now conservatively pessimistic about the traits that blacklisted types implement. #944 -
When bitfields have a ridiculously large number of bits (for example,
unsigned : 632;) thenbindgenwas incorrectly deriving traits that couldn't be derived, resulting in errors when compiling the bindings, and was also generatingstructs 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).bindgenwill 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
-
bindgenwas mis-handlingunions that contained bitfield members. This has been fixed. #744 -
Unsigned constants that were greater than
u32::MAXwere being mis-translated bybindgen. 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
bindgenwill print a more useful error message now. #1029 -
bindgenpreviously attempted to deriveHashfor structures with flexibly-sized array members, but knowing how many elements exist in such arrays requires program-specific knowledge thatbindgencannot have. #1094
Released 2017/08/28
- Explicit control over choosing which Rust version (specific stable versions or nightly Rust) to target. This defaults to the latest stable Rust version. #832
bindgen::Builder::default()
.rust_target(bindgen::RustTarget::Stable_1_19)
// or `.rust_target(bindgen::RustTarget::Nightly)` to use unstable featuresor
$ bindgen --rust-target 1.19
# or `--rust-target nightly` to use unstable features
-
Started adding
derive(Copy)for large arrays ofCopythings, even when the array is too large toderive(Clone)because Rust doesn't implementClonefor arrays of length greater than 32. #874 -
bindgencan now determine which types are hashable and addderive(Hash)to those types that support it. This is disabled by default, but can be enabled viabindgen::Builder::derive_hashor--with-derive-hash. #876 -
bindgencan now generateimpl Debug for Blahtrait implementations for types that contain non-Debugtypes, and therefore cannotderive(Debug). This behavior can be enabled withbindgen::Builder::impl_debugand--impl-debug. #875 -
bindgencan now invokerustfmton the generated bindings. The bindings have historically been fairly pretty printed, but sometimes this is not the case, especially with the newimpl Debug for Blahfeature. Havebindgenrunrustfmtwithbindgen::Builder::rustfmt_bindingsand--rustfmt-bindings, and use non-defaultrustfmtconfiguration files withbindgen::Builder::rustfmt_configuration_fileand--rustfmt-configuration-file. #900 -
bindgencan now determine which types can be compared with==and addderive(PartialEq)to those types that support it. This is disabled by default, but can be enabled viabindgen::Builder::derive_partialeqor--with-derive-partialeq. #878 -
Additionally,
bindgencan also addderive(Eq)to those types which we determined we couldderive(PartialEq)and do not transitively contain any floats. Enable this behavior withbindgen::Builder::derive_eqor--with-derive-eq. #880
-
Started emitting Rust
unions 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
Copyor 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-rustis deprecated, in favor of targeting explicit Rust versions withbindgen::Builder::rust_target/--rust-targetinstead. #832
-
Fixed a regression in the
derive(Default)analysis that resulted in some opaque types derivingDefaultwhen 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++
enums 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
enums will generate constants with names likePetKind_Hamsterinstead.Use
bindgen::Builder::constified_enum_moduleor--constified-enum-module. -
You can now mark particular template instantiations as "opaque", so that
bindgenemits 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, whichbindgendoes not yet support. Previously, it was all of a templates' instantiations would be opaque or none of them would be. Usebindgen::Builder::opaque_type("SomeTemplate<Foo, Bar>")or--opaque-type "SomeTemplate<Foo, Bar>". -
Added the ability to preprocess and dump the input headers given to
bindgento a file. This should make creating reproducible, system independent, standalone test cases much easier! Bring on the new issues! Usebindgen::Builder::dump_preprocessed_inputor--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
- The
bindgenrepository has moved under therust-lang-nurseryumbrella! 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 namespaces' names in types' names. Names of types from some STLs were showing up likestd___cxx11_basic_stringwhen they should have beenstd_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
bindgenwas 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