-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lack of support of ENUM for C #419
Comments
This issue is mainly due to the fact that size of "C enum" is an implementation defined according to the C standard. |
It is obviously possible to generate C inline function that wrap C functions and take care of conversions enum<->integer, |
Agreed for the enum returned by C.
It's also convenient, as RUST can convert ENUM to any INT. |
At least, this solves the situation where a RUST function returns an Error :
and the C code performs a switch ... case on returned value :
|
Hmm ... |
The creation of expectation test would be rather simple.
In spite of name |
OK. Thx. I'll have a look this afternoon. |
From glue.rs.in code below :
I'm able to generate something like :
This part could be considered as complet :-) Now, I wanted the C functions to use this new type. OK. I suppose that the following generated code
is generated by RUSTC itself, based on cpp_glue.rs:
Now, I understand your statment Then ... I guess that there is no way to have something like
Moreover, I found that the C code is also used by the C++ one, to complicate a bit :-) Then, I also had a look to tests/expectations. |
I figured out that .hpp is generated to expose constants for enums, but this file is not usable for pure C code.
I worked a bit on that, this afternoon.
I come to a
c_<enum_name>.h
that I'm able to include in a simple C code.But, its also a bit redundant with the already generated
<enum_name>.hpp
.I'd like to discuss this, before raising a PR.
The text was updated successfully, but these errors were encountered: