Blocklisting - The bindgen User Guide
Description: `bindgen` automatically generates Rust FFI bindings to C and C++ libraries.

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Blocklisting

If you need to provide your own custom translation of some type (for example, because you need to wrap one of its fields in an `UnsafeCell`), you can explicitly blocklist generation of its definition. Uses of the blocklisted type will still appear in other types’ definitions. (If you don’t want the type to appear in the bindings at all, make it opaque instead of blocklisting it.)

Blocklisted types are pessimistically assumed not to be able to `derive` any traits, which can transitively affect other types’ ability to `derive` traits or not.

The `blocklist-file` option also allows the blocklisting of all items from a particular path regex, for example to block all types defined in system headers that are transitively included.

### Library

- `bindgen::Builder::blocklist_file`
- `bindgen::Builder::blocklist_function`
- `bindgen::Builder::blocklist_item`
- `bindgen::Builder::blocklist_type`
- `bindgen::Builder::blocklist_var`

### Command Line

- `--blocklist-file <path>`
- `--blocklist-function <function>`
- `--blocklist-item <item>`
- `--blocklist-type <type>`
- `--blocklist-var <var>`

### Annotations

    /// <div rustbindgen hide></div>
    class Foo {
        // ...
    };