cbindgen
cbindgen copied to clipboard
C header doesn't include types for uintptr_t
If you have a c file such as:
#include <cbindings.h>
int main(...) {
...
}
And you use cbindings.h as emitted by cbindgen with language "C" provided, this will not compile due to:
unknown type name ‘uintptr_t’
10 | uintptr_t do_nothing_rust();
| ^~~~~~~~~
This is due to a missing header (probably inttypes.h) in cbindings.h
Cbindgen should itself include inttypes.h (and all other relevant types) for allow C language emitted headers to work.
Hmmm, which c compiler / library are you using? We compile all our tests to verify that they are valid C / C++ code, and we do have test-cases for uintptr_t... See tests/expectations/tag/enum.c for example.
I'm using OpenSUSE tumbleweed with gcc9. You could try this with docker run opensuse/tumbleweed:latest /bin/sh; zypper in -y gcc;
Do the cbindgen tests pass for you there? I'm surprised since I use glibc and gcc9 locally and it works.
Anyhow probably trivial to just expand the set of default includes, want to send a patch that works for you? The code to emit these is in src/bindgen/bindings.rs
.
see: https://en.cppreference.com/w/c/types/integer https://en.cppreference.com/w/cpp/types/integer