OS Manuals

/usr/bin/bindgen

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

From rust-bindgen 0.73.2-r3 (os), captured 2026-11-05 by running bindgen --help (exit 0). permalink

Generates Rust bindings from C/C++ headers.

Usage: bindgen <FLAGS> <OPTIONS> <HEADER> -- <CLANG_ARGS>...

Arguments:
  [HEADER]         C or C++ header file
  [CLANG_ARGS]...  Arguments to be passed straight through to clang

Options:
      --depfile <DEPFILE>
          Path to write depfile to
      --default-enum-style <STYLE>
          The default STYLE of code used to generate enums
      --bitfield-enum <REGEX>
          Mark any enum whose name matches REGEX as a set of bitfield flags
      --newtype-enum <REGEX>
          Mark any enum whose name matches REGEX as a newtype
      --newtype-global-enum <REGEX>
          Mark any enum whose name matches REGEX as a global newtype
      --rustified-enum <REGEX>
          Mark any enum whose name matches REGEX as a Rust enum
      --rustified-non-exhaustive-enum <REGEX>
          Mark any enum whose name matches REGEX as a non-exhaustive Rust enum
      --constified-enum <REGEX>
          Mark any enum whose name matches REGEX as a series of constants
      --constified-enum-module <REGEX>
          Mark any enum whose name matches REGEX as a module of constants
      --default-macro-constant-type <TYPE>
          The default signed/unsigned TYPE for C macro constants
      --default-alias-style <STYLE>
          The default STYLE of code used to generate typedefs
      --normal-alias <REGEX>
          Mark any typedef alias whose name matches REGEX to use normal type aliasing
      --new-type-alias <REGEX>
          Mark any typedef alias whose name matches REGEX to have a new type generated for it
      --new-type-alias-deref <REGEX>
          Mark any typedef alias whose name matches REGEX to have a new type with Deref and DerefMut to the inner type
      --default-non-copy-union-style <STYLE>
          The default STYLE of code used to generate unions with non-Copy members. Note that ManuallyDrop was first stabilized in Rust 1.20.0
      --bindgen-wrapper-union <REGEX>
          Mark any union whose name matches REGEX and who has a non-Copy member to use a bindgen-generated wrapper for fields
      --manually-drop-union <REGEX>
          Mark any union whose name matches REGEX and who has a non-Copy member to use ManuallyDrop (stabilized in Rust 1.20.0) for fields
      --blocklist-type <TYPE>
          Mark TYPE as hidden
      --blocklist-function <FUNCTION>
          Mark FUNCTION as hidden
      --blocklist-item <ITEM>
          Mark ITEM as hidden
      --blocklist-file <FILE>
          Mark FILE as hidden
      --blocklist-var <VAR>
          Mark VAR as hidden
      --no-layout-tests
          Avoid generating layout tests for any type
      --no-derive-copy
          Avoid deriving Copy on any type
      --no-derive-debug
          Avoid deriving Debug on any type
      --impl-debug
          Create a Debug implementation if it cannot be derived automatically
      --impl-partialeq
          Create a PartialEq implementation if it cannot be derived automatically
      --with-derive-default
          Derive Default on any type
      --with-derive-hash
          Derive Hash on any type
      --with-derive-partialeq
          Derive PartialEq on any type
      --with-derive-partialord
          Derive PartialOrd on any type
      --with-derive-eq
          Derive Eq on any type
      --with-derive-ord
          Derive Ord on any type
      --no-doc-comments
          Avoid including doc comments in the output, see: <https://github.com/rust-lang/rust-bindgen/issues/426>
      --no-recursive-allowlist
          Disable allowlisting types recursively. This will cause bindgen to emit Rust code that won't compile! See the `bindgen::Builder::allowlist_recursively` method's documentation for details
      --objc-extern-crate
          Use extern crate instead of use for objc
      --nonnull-references
          Use `NonNull` in place of raw pointers for C++ references
      --generate-block
          Generate block signatures instead of void pointers
      --generate-cstr
          Generate string constants as `&CStr` instead of `&[u8]`
      --block-extern-crate
          Use extern crate instead of use for block
      --distrust-clang-mangling
          Do not trust the libclang-provided mangling
      --builtins
          Output bindings for builtin definitions, e.g. __builtin_va_list
      --ctypes-prefix <PREFIX>
          Use the given PREFIX before raw types instead of ::std::os::raw
      --anon-fields-prefix <PREFIX>
          Use the given PREFIX for anonymous fields
      --time-phases
          Time the different bindgen phases and print to stderr
      --emit-clang-ast
          Output the Clang AST for debugging purposes
      --emit-ir
          Output our internal IR for debugging purposes
      --emit-ir-graphviz <PATH>
          Dump a graphviz dot file to PATH
      --enable-cxx-namespaces
          Enable support for C++ namespaces
      --disable-name-namespacing
          Disable namespacing via mangling, causing bindgen to generate names like `Baz` instead of `foo_bar_Baz` for an input name `foo::bar::Baz`
      --disable-nested-struct-naming
          Disable nested struct naming, causing bindgen to generate names like `bar` instead of `foo_bar` for a nested definition `struct foo { struct bar { } b; };`
      --disable-untagged-union
          Disable support for native Rust unions
      --disable-header-comment
          Suppress insertion of bindgen's version identifier into generated bindings
      --ignore-functions
          Do not generate bindings for functions or methods. This is useful when you only care about struct layouts
      --generate <GENERATE>
          Generate only given items, split by commas. Valid values are `functions`,`types`, `vars`, `methods`, `constructors` and `destructors`
      --ignore-methods
          Do not generate bindings for methods
      --no-convert-floats
          Do not automatically convert floats to f32/f64
      --no-prepend-enum-name
          Do not prepend the enum name to constant or newtype variants
      --no-include-path-detection
          Do not try to detect default include paths
      --fit-macro-constant-types
          Try to fit macro constants into types smaller than u32/i32
      --opaque-type <TYPE>
          Mark TYPE as opaque
  -o, --output <OUTPUT>
          Write Rust bindings to OUTPUT
      --raw-line <RAW_LINE>
          Add a raw line of Rust code at the beginning of output
      --module-raw-line <MODULE_NAME> <RAW_LINE>
          Add a RAW_LINE of Rust code to a given module with name MODULE_NAME
      --rust-target <RUST_TARGET>
          Version of the Rust compiler to target. Any Rust version after 1.51.0 is supported. Defaults to 1.82.0.
      --rust-edition <EDITION>
          Rust edition to target. Defaults to the latest edition supported by the chosen Rust target. Possible values: (2018|2021|2024).
      --use-core
          Use types from Rust core instead of std
      --conservative-inline-namespaces
          Conservatively generate inline namespaces to avoid name conflicts
      --allowlist-function <REGEX>
          Allowlist all the free-standing functions matching REGEX. Other non-allowlisted functions will not be generated
      --generate-inline-functions
          Generate inline functions
      --allowlist-type <REGEX>
          Only generate types matching REGEX. Other non-allowlisted types will not be generated
      --allowlist-var <REGEX>
          Allowlist all the free-standing variables matching REGEX. Other non-allowlisted variables will not be generated
      --allowlist-file <PATH>
          Allowlist all contents of PATH
      --allowlist-item <REGEX>
          Allowlist all items matching REGEX. Other non-allowlisted items will not be generated
      --verbose
          Print verbose error messages
      --dump-preprocessed-input
          Preprocess and dump the input header files to disk. Useful when debugging bindgen, using C-Reduce, or when filing issues. The resulting file will be named something like `__bindgen.i` or `__bindgen.ii`
      --no-record-matches
          Do not record matching items in the regex sets. This disables reporting of unused items
      --no-size_t-is-usize
          Do not bind size_t as usize (useful on platforms where those types are incompatible)
      --no-rustfmt-bindings
          Do not format the generated bindings with rustfmt. This option is deprecated, please use `--formatter=none` instead
      --formatter <FORMATTER>
          Which FORMATTER should be used for the bindings
      --rustfmt-configuration-file <PATH>
          The absolute PATH to the rustfmt configuration file. The configuration file will be used for formatting the bindings. This parameter sets `formatter` to `rustfmt`
      --no-partialeq <REGEX>
          Avoid deriving PartialEq for types matching REGEX
      --no-copy <REGEX>
          Avoid deriving Copy and Clone for types matching REGEX
      --no-debug <REGEX>
          Avoid deriving Debug for types matching REGEX
      --no-default <REGEX>
          Avoid deriving/implementing Default for types matching REGEX
      --no-hash <REGEX>
          Avoid deriving Hash for types matching REGEX
      --must-use-type <REGEX>
          Add `#[must_use]` annotation to types matching REGEX
      --enable-function-attribute-detection
          Enables detecting unexposed attributes in functions (slow). Used to generate `#[must_use]` annotations
      --use-array-pointers-in-arguments
          Use `*const [T; size]` instead of `*const T` for C arrays
      --wasm-import-module-name <NAME>
          The NAME to be used in a #[link(wasm_import_module = ...)] statement
      --extern-block-attrs <ATTRS>
          Attributes to apply to extern blocks
      --dynamic-loading <NAME>
          Use dynamic loading mode with the given library NAME
      --dynamic-link-require-all
          Require successful linkage to all functions in the library
      --prefix-link-name <PREFIX_LINK_NAME>
          Prefix the name of exported symbols
      --respect-cxx-access-specs
          Makes generated bindings `pub` only for items if the items are publicly accessible in C++
      --translate-enum-integer-types
          Always translate enum integer types to native Rust integer types
      --c-naming
          Generate types with C style naming
      --explicit-padding
          Always output explicit padding fields
      --use-specific-virtual-function-receiver
          Always be specific about the 'receiver' of a virtual function
      --use-distinct-char16-t
          Use distinct char16_t
      --represent-cxx-operators
          Output C++ overloaded operators
      --vtable-generation
          Enables generation of vtable functions
      --sort-semantically
          Enables sorting of code generation in a predefined manner
      --merge-extern-blocks
          Deduplicates extern blocks
      --override-abi <OVERRIDE>
          Overrides the ABI of functions matching REGEX. The OVERRIDE value must be of the shape REGEX=ABI where ABI can be one of C, stdcall, efiapi, fastcall, thiscall, aapcs, win64 or C-unwind<.>
      --wrap-unsafe-ops
          Wrap unsafe operations in unsafe blocks
      --clang-macro-fallback
          Enable fallback for clang macro parsing
      --clang-macro-fallback-build-dir <CLANG_MACRO_FALLBACK_BUILD_DIR>
          Set path for temporary files generated by fallback for clang macro parsing
      --flexarray-dst
          Use DSTs to represent structures with flexible array members
      --with-derive-custom <CUSTOM>
          Derive custom traits on any kind of type. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a comma-separated list of derive macros
      --with-derive-custom-struct <CUSTOM>
          Derive custom traits on a `struct`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a comma-separated list of derive macros
      --with-derive-custom-enum <CUSTOM>
          Derive custom traits on an `enum`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a comma-separated list of derive macros
      --with-derive-custom-union <CUSTOM>
          Derive custom traits on a `union`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a comma-separated list of derive macros
      --with-attribute-custom <CUSTOM>
          Add custom attributes on any kind of type. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a comma-separated list of attributes
      --with-attribute-custom-struct <CUSTOM>
          Add custom attributes on a `struct`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a comma-separated list of attributes
      --with-attribute-custom-enum <CUSTOM>
          Add custom attributes on an `enum`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a comma-separated list of attributes
      --with-attribute-custom-union <CUSTOM>
          Add custom attributes on a `union`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a comma-separated list of attributes
      --wrap-static-fns
          Generate wrappers for `static` and `static inline` functions
      --wrap-static-fns-path <PATH>
          Sets the PATH for the source file that must be created due to the presence of `static` and `static inline` functions
      --wrap-static-fns-suffix <SUFFIX>
          Sets the SUFFIX added to the extern wrapper functions generated for `static` and `static inline` functions
      --default-visibility <VISIBILITY>
          Set the default VISIBILITY of fields, including bitfields and accessor methods for bitfields. This flag is ignored if the `--respect-cxx-access-specs` flag is used
      --generate-deleted-functions
          Whether to generate C++ functions marked with "=delete" even though they can't be called
      --generate-pure-virtual-functions
          Whether to generate C++ "pure virtual" functions even though they can't be called
      --generate-private-functions
          Whether to generate C++ private functions even though they can't be called
      --field-attr <SPEC>
          Add a custom attribute to a field. The SPEC value must be of the shape TYPE::FIELD=ATTR
      --emit-diagnostics
          Whether to emit diagnostics or not
      --generate-shell-completions <SHELL>
          Generates completions for the specified SHELL, sends them to `stdout` and exits [possible values: bash, elvish, fish, powershell, zsh]
      --experimental
          Enables experimental features
  -V, --version
          Prints the version, and exits
  -h, --help
          Print help
Options (129)
OptionDescriptionSource
--depfile DEPFILEPath to write depfile tohelp
--default-enum-style STYLEThe default STYLE of code used to generate enumshelp
--bitfield-enum REGEXMark any enum whose name matches REGEX as a set of bitfield flagshelp
--newtype-enum REGEXMark any enum whose name matches REGEX as a newtypehelp
--newtype-global-enum REGEXMark any enum whose name matches REGEX as a global newtypehelp
--rustified-enum REGEXMark any enum whose name matches REGEX as a Rust enumhelp
--rustified-non-exhaustive-enum REGEXMark any enum whose name matches REGEX as a non-exhaustive Rust enumhelp
--constified-enum REGEXMark any enum whose name matches REGEX as a series of constantshelp
--constified-enum-module REGEXMark any enum whose name matches REGEX as a module of constantshelp
--default-macro-constant-type TYPEThe default signed/unsigned TYPE for C macro constantshelp
--default-alias-style STYLEThe default STYLE of code used to generate typedefshelp
--normal-alias REGEXMark any typedef alias whose name matches REGEX to use normal type aliasinghelp
--new-type-alias REGEXMark any typedef alias whose name matches REGEX to have a new type generated for ithelp
--new-type-alias-deref REGEXMark any typedef alias whose name matches REGEX to have a new type with Deref and DerefMut to the inner typehelp
--default-non-copy-union-style STYLEThe default STYLE of code used to generate unions with non-Copy members.help
--bindgen-wrapper-union REGEXMark any union whose name matches REGEX and who has a non-Copy member to use a bindgen-generated wrapper for fieldshelp
--manually-drop-union REGEXMark any union whose name matches REGEX and who has a non-Copy member to use ManuallyDrop (stabilized in Rust 1.20.0) for fieldshelp
--blocklist-type TYPEMark TYPE as hiddenhelp
--blocklist-function FUNCTIONMark FUNCTION as hiddenhelp
--blocklist-item ITEMMark ITEM as hiddenhelp
--blocklist-file FILEMark FILE as hiddenhelp
--blocklist-var VARMark VAR as hiddenhelp
--no-layout-testsAvoid generating layout tests for any typehelp
--no-derive-copyAvoid deriving Copy on any typehelp
--no-derive-debugAvoid deriving Debug on any typehelp
--impl-debugCreate a Debug implementation if it cannot be derived automaticallyhelp
--impl-partialeqCreate a PartialEq implementation if it cannot be derived automaticallyhelp
--with-derive-defaultDerive Default on any typehelp
--with-derive-hashDerive Hash on any typehelp
--with-derive-partialeqDerive PartialEq on any typehelp
--with-derive-partialordDerive PartialOrd on any typehelp
--with-derive-eqDerive Eq on any typehelp
--with-derive-ordDerive Ord on any typehelp
--no-doc-commentsAvoid including doc comments in the output, see: <https://github.com/rust-lang/rust-bindgen/issues/426>help
--no-recursive-allowlistDisable allowlisting types recursively.help
--objc-extern-crateUse extern crate instead of use for objchelp
--nonnull-referencesUse `NonNull` in place of raw pointers for C++ referenceshelp
--generate-blockGenerate block signatures instead of void pointershelp
--generate-cstrGenerate string constants as `&CStr` instead of `&[u8]`help
--block-extern-crateUse extern crate instead of use for blockhelp
--distrust-clang-manglingDo not trust the libclang-provided manglinghelp
--builtinsOutput bindings for builtin definitions, e.g. __builtin_va_listhelp
--ctypes-prefix PREFIXUse the given PREFIX before raw types instead of ::std::os::rawhelp
--anon-fields-prefix PREFIXUse the given PREFIX for anonymous fieldshelp
--time-phasesTime the different bindgen phases and print to stderrhelp
--emit-clang-astOutput the Clang AST for debugging purposeshelp
--emit-irOutput our internal IR for debugging purposeshelp
--emit-ir-graphviz PATHDump a graphviz dot file to PATHhelp
--enable-cxx-namespacesEnable support for C++ namespaceshelp
--disable-name-namespacingDisable namespacing via mangling, causing bindgen to generate names like `Baz` instead of `foo_bar_Baz` for an input name `foo::bar::Baz`help
--disable-nested-struct-namingDisable nested struct naming, causing bindgen to generate names like `bar` instead of `foo_bar` for a nested definition `struct foo { struct bar { } b;help
--disable-untagged-unionDisable support for native Rust unionshelp
--disable-header-commentSuppress insertion of bindgen's version identifier into generated bindingshelp
--ignore-functionsDo not generate bindings for functions or methods.help
--generate GENERATEGenerate only given items, split by commas.help
--ignore-methodsDo not generate bindings for methodshelp
--no-convert-floatsDo not automatically convert floats to f32/f64help
--no-prepend-enum-nameDo not prepend the enum name to constant or newtype variantshelp
--no-include-path-detectionDo not try to detect default include pathshelp
--fit-macro-constant-typesTry to fit macro constants into types smaller than u32/i32help
--opaque-type TYPEMark TYPE as opaquehelp
-o, --output OUTPUTWrite Rust bindings to OUTPUThelp
--raw-line RAW_LINEAdd a raw line of Rust code at the beginning of outputhelp
--rust-target RUST_TARGETVersion of the Rust compiler to target.help
--rust-edition EDITIONRust edition to target.help
--use-coreUse types from Rust core instead of stdhelp
--conservative-inline-namespacesConservatively generate inline namespaces to avoid name conflictshelp
--allowlist-function REGEXAllowlist all the free-standing functions matching REGEX.help
--generate-inline-functionsGenerate inline functionshelp
--allowlist-type REGEXOnly generate types matching REGEX.help
--allowlist-var REGEXAllowlist all the free-standing variables matching REGEX.help
--allowlist-file PATHAllowlist all contents of PATHhelp
--allowlist-item REGEXAllowlist all items matching REGEX.help
--verbosePrint verbose error messageshelp
--dump-preprocessed-inputPreprocess and dump the input header files to disk.help
--no-record-matchesDo not record matching items in the regex sets.help
--no-size_t-is-usizeDo not bind size_t as usize (useful on platforms where those types are incompatible)help
--no-rustfmt-bindingsDo not format the generated bindings with rustfmt.help
--formatter FORMATTERWhich FORMATTER should be used for the bindingshelp
--rustfmt-configuration-file PATHThe absolute PATH to the rustfmt configuration file.help
--no-partialeq REGEXAvoid deriving PartialEq for types matching REGEXhelp
--no-copy REGEXAvoid deriving Copy and Clone for types matching REGEXhelp
--no-debug REGEXAvoid deriving Debug for types matching REGEXhelp
--no-default REGEXAvoid deriving/implementing Default for types matching REGEXhelp
--no-hash REGEXAvoid deriving Hash for types matching REGEXhelp
--must-use-type REGEXAdd `#[must_use]` annotation to types matching REGEXhelp
--enable-function-attribute-detectionEnables detecting unexposed attributes in functions (slow).help
--use-array-pointers-in-argumentsUse `*const [T;help
--wasm-import-module-name NAMEThe NAME to be used in a #[link(wasm_import_module = ...)] statementhelp
--extern-block-attrs ATTRSAttributes to apply to extern blockshelp
--dynamic-loading NAMEUse dynamic loading mode with the given library NAMEhelp
--dynamic-link-require-allRequire successful linkage to all functions in the libraryhelp
--prefix-link-name PREFIX_LINK_NAMEPrefix the name of exported symbolshelp
--respect-cxx-access-specsMakes generated bindings `pub` only for items if the items are publicly accessible in C++help
--translate-enum-integer-typesAlways translate enum integer types to native Rust integer typeshelp
--c-namingGenerate types with C style naminghelp
--explicit-paddingAlways output explicit padding fieldshelp
--use-specific-virtual-function-receiverAlways be specific about the 'receiver' of a virtual functionhelp
--use-distinct-char16-tUse distinct char16_thelp
--represent-cxx-operatorsOutput C++ overloaded operatorshelp
--vtable-generationEnables generation of vtable functionshelp
--sort-semanticallyEnables sorting of code generation in a predefined mannerhelp
--merge-extern-blocksDeduplicates extern blockshelp
--override-abi OVERRIDEOverrides the ABI of functions matching REGEX.help
--wrap-unsafe-opsWrap unsafe operations in unsafe blockshelp
--clang-macro-fallbackEnable fallback for clang macro parsinghelp
--clang-macro-fallback-build-dir CLANG_MACRO_FALLBACK_BUILD_DIRSet path for temporary files generated by fallback for clang macro parsinghelp
--flexarray-dstUse DSTs to represent structures with flexible array membershelp
--with-derive-custom CUSTOMDerive custom traits on any kind of type.help
--with-derive-custom-struct CUSTOMDerive custom traits on a `struct`.help
--with-derive-custom-enum CUSTOMDerive custom traits on an `enum`.help
--with-derive-custom-union CUSTOMDerive custom traits on a `union`.help
--with-attribute-custom CUSTOMAdd custom attributes on any kind of type.help
--with-attribute-custom-struct CUSTOMAdd custom attributes on a `struct`.help
--with-attribute-custom-enum CUSTOMAdd custom attributes on an `enum`.help
--with-attribute-custom-union CUSTOMAdd custom attributes on a `union`.help
--wrap-static-fnsGenerate wrappers for `static` and `static inline` functionshelp
--wrap-static-fns-path PATHSets the PATH for the source file that must be created due to the presence of `static` and `static inline` functionshelp
--wrap-static-fns-suffix SUFFIXSets the SUFFIX added to the extern wrapper functions generated for `static` and `static inline` functionshelp
--default-visibility VISIBILITYSet the default VISIBILITY of fields, including bitfields and accessor methods for bitfields.help
--generate-deleted-functionsWhether to generate C++ functions marked with "=delete" even though they can't be calledhelp
--generate-pure-virtual-functionsWhether to generate C++ "pure virtual" functions even though they can't be calledhelp
--generate-private-functionsWhether to generate C++ private functions even though they can't be calledhelp
--field-attr SPECAdd a custom attribute to a field.help
--emit-diagnosticsWhether to emit diagnostics or nothelp
--generate-shell-completions SHELLGenerates completions for the specified SHELL, sends them to `stdout` and exits [possible values: bash, elvish, fish, powershell, zsh]help
--experimentalEnables experimental featureshelp
-V, --versionPrints the version, and exitshelp
-h, --helpPrint helphelp

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.