cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Cannot redefine `stdint` types

Open CATboardBETA opened this issue 3 years ago • 3 comments

I'm writing an implementation of the C standard library. Thus, I am defining types like uint16_t. When I use pub type int16_t = libc::c_short;, nothing gets generated. However, if I use pub type some_other_name = libc::c_short;, it does get generated (of course, assuming there is a usage).

How can I generate these types anyways?

CATboardBETA avatar Aug 15 '22 12:08 CATboardBETA

Hmm, a bit edge case-y. PrimitiveType::maybe seems to special-case these names, but I'm a bit confused as of why, since the input is supposed to be a rust type, not a C/C++ type... :)

emilio avatar Aug 16 '22 07:08 emilio

Ah, blaming it seems this was added in https://github.com/eqrion/cbindgen/pull/130 (without tests :/).

libc::int8_t and so on are deprecated, maybe removing those particular special cases is sensible (though there's a few more like ptrdiff_t which seems unfortunate to remove).

emilio avatar Aug 16 '22 07:08 emilio

I think the only reasonable solution @emilio would honestly probably be a rewrite of cbindgen so that it understands the module system.

I guess for the time being I can just use the rename annotation

CATboardBETA avatar Aug 17 '22 00:08 CATboardBETA