Sean1708 / rusty-cheddar

A Rust crate for automatically generating C header files from Rust source file.
http://sean1708.github.io/rusty-cheddar/
191 stars 25 forks source link

Namespace generated enum members with the name of the enum. #35

Closed kinetiknz closed 2 years ago

kinetiknz commented 8 years ago

Rust enum members are namespaced by the enum, whereas C enum members leak into the containing namespace. This makes constructs such as:

#[repr(C)]
pub enum Foo {
    WIN = 1,
    LOSE = 2,
}

#[repr(C)]
pub enum Bar {
    WIN = 3,
    LOSE = 4,
}

...ambiguous within C when they're valid in Rust. The solution offered in this PR is to prefix the enum members with the enum's name to provide a form of namespacing.

I'm not sure if you'd merge this as-is because it breaks compatibility with existing output

Sean1708 commented 8 years ago

Hi @kinetiknz, thanks for the PR. I'm working on a major refactor at the moment which will inevitably introduce some breaking changes, so it can be merged along with that.

rillian commented 8 years ago

@Sean1708 This is still an issue for us. What can we do to help get this addressed?