This adds a new rename-all annotation which allows setting a specific
prefix to all fields. For example:
```rust
/// cbindgen:rename-all=prefix:ERR_
enum Error {
Bad = 0,
VeryBad = 1
}
```
While in principle this can be added to the config file, it's primarily
useful for overrides on a case-by-case basis.
All zero-sized structs now trigger a warning about undefined behavior,
and an empty struct definition is emitted regardless of whether the user
asked for repr(C) or repr(transparent).
This is a trap "for young players" and loosing feedback from rustc or
your favorite code analysis tools won't make things better. Let's point
out the issue and the solution given in issue #472 upfront.
The new command line argument for this is --package-version.
The TOML config file flag is package_version=true||false.
Closes#926
Co-Authored-By: Emilio Cobos Álvarez <emilio@crisal.io>
While the #[deprecated] attribute was already used on structs, fns and
enums, it was not implemented for enum variants. The information about
enum variants is already available via `variant.body.annotations`, so
the support for the #[deprecated] attribute on enum-variant level is
more or less only another pair of entries within the `EnumConfig`.
This commit adds two new options within the `[enum]` settings:
- deprecated_variant, and
- deprecated_variant_with_notes
Both get active only on #[deprecated] variants, e.g.,
#[repr(u8)]
enum ApiLevel {
#[deprecated(note = "Legacy Support until 2025")]
L1 = 1,
#[deprecated]
L2 = 2,
L3 = 3,
L4 = 4,
}
For enums with struct variants, the current struct deprecation methods
are already working good enough (see tests/expecations/deprecated*).
- the old code was selecting the first package that was found which meant
that dependencies with the same name could be used for bindgen instead of
the intended package
- a fallback to the old behavior is kept for now in case manifest paths are
not matching because of relative paths for example
- this should be backwards compatible with all cbindgen usage, the
selection bug may still trigger in case the manifest path does not match