Skip to content

Commit

Permalink
Point out issue with failing builds due to syntax errors
Browse files Browse the repository at this point in the history
This is a trap "for young players" an 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 mozilla#472 upfront.
  • Loading branch information
sirhcel committed May 22, 2024
1 parent 85de534 commit 2a52b57
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ fn main() {

You can add configuration options using the [`Builder`](https://docs.rs/cbindgen/*/cbindgen/struct.Builder.html#methods) interface.

When actively working on code, you likely don't want cbindgen to fail the entire build. Instead of expect-ing the result of the header generation, you could [ignore parse errors](https://github.com/mozilla/cbindgen/issues/472#issuecomment-831439826) and let rustc or your code analysis bring up:

```rust
// ...
.generate()
.map_or_else(
|error| match error {
cbindgen::Error::ParseSyntaxError { .. } => {}
e => panic!("{:?}", e),
},
|bindings| {
bindings.write_to_file("target/include/edrs.h");
},
);
}
```

Be sure to add the following section to your Cargo.toml:

```
Expand Down

0 comments on commit 2a52b57

Please sign in to comment.