Hello, I feel like there's a noticeable issue with C interoperability, specifically regarding macros.
In this case I found myself with a curious issue when moving from SDL2 to SDL3:
#define SDL_WINDOW_HIGH_PIXEL_DENSITY SDL_UINT64_C(0x0000000000002000) /**< window uses high pixel density back buffer if possible */
The constants are now defined with a special macro that chooses the correct type for the literal based on platform to match the size, and Swift can no longer import these.
I will never understand C developers, I don't think this has any need to be a define, but in the end it's not really in issue with the library but Swift.
I'm not sure how this could best be solved, but maybe Swift could try to evaluate more complex macros as long as they can be evaluated to a simple constant?
I’ve had the same problem with the same kind of macros before. (probably with SDL actually!)
In modern C you can use appropriately sized enums to declare constants but a lot of projects want to keep supporting C99 where enums are only ever int. const variables don’t count as constants for the language, I think this might change with the constexpr proposal but I think that’s C2y.
There’s a fun thread about using at least C99 in SDL instead of C89 in the SDL3 codebase and they’ve actually landed on C89 for public headers and C90-ish for internal codebase.
They discuss the reason for using such an old standard and link to other projects’ decisions on the matter!
I suppose I shouldn't judge, ancient hardware is cool, personally I would like to try compiling Swift for my old PSP — which SDL even supports. I wonder if Embedded Swift can target it yet