Comments (4)
That's kind of intentional, because functions taking a node_kinds
would need to accept a c-int (would break the ABI otherwise).
from rust-bindgen.
Same for structs containing it or what not. Thus, not clear it's a bug, would be rather dangerous to do as proposed. But please reopen if you disagree or I've gotten something wrong.
from rust-bindgen.
@emilio Sorry, my example had too little context.
I get your point but in this case, the real public type is node_kind (u16), not node_kinds (c_int), i.e.:
typedef uint16_t node_kind;
// node_kinds exposes the valid values as a convenience,
// but the type itself is never used in the API
enum node_kinds {
NODE_KIND_FOO = 1,
// ... lotta kinds
};
typedef struct _node {
node_kind kind; // uint16_t
// ...
} node;
node* node_new_empty(node_kind kind); // takes an uint16_t
There are many other places like this in the library, where:
- the API uses a specific integer type
T
(notc_int
) - an
enum
exposes the valid values forT
as a convenience but the enum is never used as a type in the API
It gets even more annoying when #define
d constants are involved since you have to juggle between c_int
, u32
and u16
when it really should be just u16
everywhere.
Thus, not clear it's a bug,
Let's say it's a feature request then. 😉
I can open another issue (or update the OP) with a more accurate description of the use-case if you want.
would be rather dangerous to do as proposed.
Of course, if implemented it should definitely be opt-in.
There could also be a safeguard, i.e. fail to compile if the enum type is used as a function argument or return type?
But please reopen if you disagree or I've gotten something wrong.
Please note that regular users cannot reopen issues on this tracker.
from rust-bindgen.
reopening as per the above though I still think it'd be rather footgunny.
from rust-bindgen.
Related Issues (20)
- AArch64 Linux va_list not FFI-safe
- "rustified_non_exhaustive_enum" not supported in CLI
- 0.69 introduces issue with constantly rebuilding
- bindgen has bumped MSRV without updating semver HOT 5
- `rewriting static` string in generated bindings HOT 10
- Generated INFINITY & NEG_ INFINITY are invalid in Rust 1.79
- Cannot call function that returns custom type when destructor is present.
- C++ ABI in MSVC and function returning non-POD type HOT 2
- std::size_t declared with using ::size_t does not get usize treatment
- Idea: Add firefox to CI
- Silently wrong code generated for enums in templated classes HOT 3
- Idea: Support compilation/cc-rs interface HOT 1
- bindgen generating `i64` instead of `u64` HOT 2
- Best practices for multiple large header files?
- Incorrect field offset when C struct is __attribute__((packed, aligned(8)))
- Windows keeps using MSVC, even when `CC` and `CXX` are set explicitly and empty `PATH` HOT 3
- Bindings for define statements using scientific notation HOT 2
- Panic: Couldn't resolve constant type, and it wasn't an nondeductible auto type or unexposed type! HOT 2
- How to handle C array of undefined size? HOT 1
- Installing bindgen twice with `cargo install --locked` creates different binaries. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-bindgen.