Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c2hs - anonymous enums?

Tags:

haskell

ghc

c2hs

The c2hs reference (aka 'Tutorial') mentions the name of the C enum as a non-optional parameter. Is there any way to get it to work with anonymous enums? Determining which enum to generate should be possible given just a single enum member, or even if that's not possible it should at least be possible to generate an enum by explicitly naming it's members.

To clarify:

given an enum

enum {
A,
B,
C,
D
};

I'd like something along the lines of

{#enum {A,B,C,D} as MyEnum #}
like image 226
Cubic Avatar asked Feb 11 '26 05:02

Cubic


1 Answers

enum define works (contrary to the documentation)

{# enum define MyEnum { A as A, B as B, C as C, D as D } #}
like image 177
yiding Avatar answered Feb 13 '26 17:02

yiding