Incorrect C header generated on typed enum
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3k
- Forks
- 386
- Avg merge
- 1h 43m
- Merged PRs (30d)
- 1
Description
On Rust,
#[repr(i32)
pub enum MyEnum {
EnumA,
EnumB,
}
The generated C header is wrong (with duplicated definitions):
enum MyEnum {
EnumA,
EnumB
};
typedef int32_t MyEnum;
To fix the duplicated definitions, the C header should be like this:
enum {
EnumA,
EnumB
};
typedef int32_t MyEnum;
In additional, with cpp_compat = true, the C/C++ compatible header should be like this:
enum
#ifdef __cplusplus
MyEnum : int32_t
#endif // __cplusplus
{
EnumA,
EnumB
};
#ifndef __cplusplus
typedef int32_t MyEnum;
#endif // __cplusplus
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
Reproduce the issue with the Rust typed enum shown in the report and inspect cbindgen's generated C and C++-compatible headers. The work is done when the output matches the requested unnamed enum form for C and the conditional MyEnum declaration for cpp_compat=true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100