haskell / c2hs

c2hs is a pre-processor for Haskell FFI bindings to C libraries
http://hackage.haskell.org/package/c2hs
Other
198 stars 50 forks source link

Anonymous enums within structs not supported #190

Open gilgamec opened 7 years ago

gilgamec commented 7 years ago

The #enum binding can bind named enums by name, or anonymous enums by referencing one of the values. However, it cannot reference anonymous enums which are defined within a struct (named enums in structs work fine).

If the header file is

struct Baz {
  enum { FOO = 0 , BAR = 1 } baz;
};

then the binding

{#enum FOO as FooBar {underscoreToCase} #}

fails with

Unknown identifier!
  Cannot find a definition for `FOO' in the header file.

The same binding works if the enum is declared at global scope.