Skip to content

Discussion: Consider typedef enum a few types that are currently just typedef #12339

Open
@Lancelotbronner

Description

I'm working on Swift bindings for SDL3, the language's convention-based automatic C interop helps a lot but does the wrong thing in a few places, forcing me to redefine large sets of constants.

Since some of those are inconsistent depending on API, seems like mostly flags as well. I thought I'd still open the discussion.

I'm guessing this has to do with C's default int type for enums, but I'm hoping maybe its just that a few were missed (like SDL_keymod which definitely fits in an int).

The APIs I've encountered (or spotted in the headers) so far, no doubt I'm missing a few, are:

  • SDL_PenInputFlags
  • SDL_InitFlags
  • SDL_MessageBoxFlags
  • SDL_MessageBoxButtonFlags
  • SDL_BlendMode
  • SDL_SurfaceFlags
  • SDL_WindowFlags
  • SDL_Keycode (this one hurts a lot)
  • SDL_keymod

Some additional Swift issues, which don't pertain to SDL but just for completeness sake, or in case someone magically has a fix:

  • Any "complex" macros (ie. more than a literal constant) fail to import so I had to eg. duplicate logic from SDL's version macros
  • All opaque pointers lose their type safety. Less type-safe than C is wild.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions