|
Hi! I'm trying to do some game-dev with SDL3, and I'm mapping extern types and functions as I need them. I stumbled upon the Event union, and I was wondering how So should handle union types. I guess defining a Go struct for an extern type should be no problem, but is there any way to express the same concept from Go to C (maybe with a //so directive)? |
Replies: 2 comments 1 reply
|
Hey Alessandro, thanks for your interest in Solod! You declare union types as regular structs with the //so:extern SDL_CommonEvent
type SDL_CommonEvent struct {
// ...
}
//so:extern SDL_DisplayEvent
type SDL_DisplayEvent struct {
// ...
}
//so:extern SDL_Event
type SDL_Event struct {
common SDL_CommonEvent
display SDL_DisplayEvent
// ...
} |
|
One more thing: you might want to use sobind to generate bindings instead of writing them by hand. I'm not sure they'll be 100% accurate because SDL is pretty complex, but it's probably a good place to start. If you decide to do this, make sure to install the latest versions of |
Hey Alessandro, thanks for your interest in Solod! You declare union types as regular structs with the
so:externdirective: