jckarter/clay — Issue #71: inconvenient handling of enums by bindgen
Author: Blei
Created: 2011-12-19 10:54:36+00:00
State: open

The following C header:

```c
typedef enum {
FOO = 1,
} my_enum;

void callWithEnum(my_enum e);
```

gets generated as:

```
/* automatically generated by clay-bindgen */

alias Enum_Unnamed1 = UInt;
alias FOO = 1;

alias my_enum = Opaque /* unknown EnumDecl */;

external (cdecl) callWithEnum(arg0:my_enum) : ;
```

The problem is that `callWithEnum` expects a `my_enum` value as input. This is an alias to `Opaque` which is a `Byte`. The generated enums on the other hand are `Int`s, so type checking fails. It's of course possible to cast all enum values by hand, but it's very inconvenient.

How about something like:

```
alias Enum_Unnamed1 = UInt;
alias FOO = Enum_Unnamed1(1);
alias my_enum = Enum_Unnamed1;
```