bindings-dsl
bindings-dsl copied to clipboard
Structs with unnamed union fields
How do I generate a type definition for structs with unnamed unions?
For example:
typedef struct clap_window {
const char * api;
union {
clap_nsview cocoa;
clap_xwnd x11;
clap_hwnd win32;
void * ptr;
}
} clap_window_t;
Giving the field an arbitrary name doesn't work, nor does giving it no name. And when I generated bindings using c2hsc
, the second field was omitted entirely.
#starttype struct clap_window
#field api , CString
#field window.cocoa , clap_nsview
#field window.x11 , clap_xwnd
#field window.win32 , clap_hwnd
#field window.ptr , Ptr ()
#stoptype
error: ‘struct clap_window’ has no member named ‘window’
#starttype struct clap_window
#field api , CString
#field .cocoa , clap_nsview
#field .x11 , clap_xwnd
#field .win32 , clap_hwnd
#field .ptr , Ptr ()
#stoptype
error: expected identifier before ‘.’ token