Skip to content

Incorrect C header generated on typed enum #1127

Description

@kennykwok

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions