rust-lang / rust-lang/rust-bindgen
wrap-static-fns converts _Bool to bool, causing a compile error
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
I made a little wrapper header using _Bool to avoid having to include stdbool.h since I was being lazy and didn't want to exclude a few symbols. It translated the _Bool to bool in the wrap-static-fns generated wrapper, which caused a compilation failure.
(Workaround: Just use stdbool. It’s not a big deal to filter out the few definitions.)
Input C/C++ Header
static inline _Bool example() { return 1; }
Bindgen Invocation
$ bindgen input.h --experimental --wrap-static-fns --wrap-static-fns-path=wrapper
Actual Results
It generates this wrapper, with _Bool translated to bool.
#include "input.h"
// Static wrappers
bool example__extern(void) { return example(); }
which produces this error:
wrapper.c:5:1: error: unknown type name 'bool'
bool example__extern(void) { return example(); }
^
1 error generated.
Expected Results
The generated wrappers should use _Bool as provided in the input.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the --wrap-static-fns entry point using the provided input.h and bindgen invocation, then inspect how the generated wrapper represents the _Bool return type. Done means the wrapper uses _Bool as expected and wrapper.c compiles without the unknown type name error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100