SDL2: SDL_mutex.h violates C90
Recently I met a failure at the SDL_mutex.h when including it in C90-enforced project:
SDL_mutex.h:42:48: error: expected declaration specifiers before ‘/’ token
42 | #define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
| ^
In addition, there is a warning at anonymous variadic macros given:
SDL_mutex.h:57:29: warning: anonymous variadic macros were introduced in C99 [-Wvariadic-macros]
57 | #define SDL_ACQUIRED_BEFORE(...) \
| ^~~
I fixed the C++ comment, but I'm not sure what can be done about the varargs macros, so I'm going to leave that to someone else to look at.
Speaking about anonymous variadic macros, maybe just add the ability to hide these macros at all? like:
#ifndef SDL_MUTEX_DISABLE_ANNOTATION_ATTRIBUTE_MACROS
/* ... */
#endif
So, user at the application could specify the SDL_MUTEX_DISABLE_ANNOTATION_ATTRIBUTE_MACROS macro to avoid them at all. It shouldn't affect existing stuff because it will be undefined by default.
What do you think?
Also, maybe make them being single-entry? Because I hadn't found any uses with multiple entries listed...
EDIT: there is only SDL_TRY_ACQUIRE() is being used with two arguments, so, "x, y" for it.
I made an experimental thing just for myself: https://github.com/WohlSoft/AudioCodecs/commit/5e567e26097d2f5a86ba4a0f7ecae70d59805fb0 If seems fine, you can take it into mainstream.
Added, thanks!