In modern C (post-C99) it's common to just use `// double-slash comments`, but currently cbindgen provides only `/* block-comment */` and `/// triple-slash comment` variants.
* Ignoring IDE files.
* Addresses issue #302, also amends #59 insofar that vanilla C-style now does not prefix individual lines with `*` anymore.
* Removed Javadoc reference.
* Renamed `Doxylight` to `Doxy` and changed C default to that.
* Added documentation.
* Changed enum name and applied `fmt`.
* Fixed comment.
* Fixed match.
This fixes one of my pet-peeves. Without this patch, I need to add them manually
using the raw body stuff, or along the code that accesses the struct member,
none of those being ideal.
Opt-in since it uses a C++17 feature, but this allow exactly the same usage in
C++ and Rust, which I think is nice.
This also fixes constants of transparent structs in general, since the initial
version of this patch broke a test (associated constants in enums), so I added a
test for that too.
Currently, `cbindgen` uses the `--all-features` flag when expanding a
dependent crate. However, this may not be desirable in a number of
cases:
- Some C APIs may be gated by a feature flag and would not be present
in the final cdylib depending on the features provided (for instance
one could want to have the ability to build a "debug" version of the
library which provides extra unstable hooks). In such cases, a
programmatic `cbindgen` call in a build script would want to use only
the features that will get used in the current build.
- Some features may bring in large dependencies and/or potentially
increase compilation time without affecting the FFI surface, and it
would be faster and more efficient to disable them when running
`cbindgen`.
- Some features may require external libraries and/or hardware (e.g.
dependencies on GPU libraries such as CUDA) that may not be available
on the current machine without affecting the FFI surface.
To alleviate this problem, this PR adds an extended version of the
`parse.expand` configuration key, allowing control over the features
used when expanding in a way similar to the way cargo handles extended
dependencies (although note that there is a single version of each key,
since the features refer to the features of the current crate). So for
instance instead of writing `expand = ["euclid"]` one would write:
```
[parse.expand]
crates = ["euclid"]
```
which is equivalent to:
```
[parse.expand]
crates = ["euclid"]
all_features = false
default_features = true
features = ["feature1", "feature2"]
```
Note that `all_features` is set to `false` by default in order to match
cargo's behavior.
For backwards compatibility, the old syntax `expand = ["euclid"]` is
still supported and is equivalent to:
```
[parse.expand]
crates = ["euclid"]
all_features = true
default_features = true
features = null
```
In this case, `all_features` is set to `true` in order to match the
previous behavior of cbindgen.
Allow structs, enums and unions to be declared as:
struct Name {};
typedef struct {} Name;
typedef struct Name {} Name;
Opaque enums will be declared as:
struct Name;
typedef struct Name Name;