I try to build SDL2 with GCC 6.2.0 but I get these errors:
Code:
src/SDL.c:84:12: error: cannot initialize return object of type ‘SDL_bool’ with an rvalue of type 'bool’
return (SDL_SubsystemRefCount[subsystem_index] == 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/SDL.c:98:12: error: cannot initialize return object of type ‘SDL_bool’ with an rvalue of type 'bool’
return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
In other words I have a problem with these two functions in SDL.c:
Code:
/* Private helper to check if a system needs init. */
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
return (SDL_SubsystemRefCount[subsystem_index] == 0); // <-- HERE THE FIRST ONE
}
…
/* Private helper to check if a system needs to be quit. */
static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (SDL_SubsystemRefCount[subsystem_index] == 0) {
return SDL_FALSE;
}
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
* isn't zero.
*/
return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit; // <-- HERE THE SECOND ONE
Code:
/* Private helper to check if a system needs init. */
static SDL_bool
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
{
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
SDL_assert(SDL_SubsystemRefCount[subsystem_index] < 255);
SDL_bool result = (SDL_SubsystemRefCount[subsystem_index] == 0) ? SDL_TRUE : SDL_FALSE;
//return (SDL_SubsystemRefCount[subsystem_index] == 0);
return result;
}
/* Private helper to check if a system needs to be quit. */
static SDL_bool
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
if (SDL_SubsystemRefCount[subsystem_index] == 0) {
return SDL_FALSE;
}
/* If we're in SDL_Quit, we shut down every subsystem, even if refcount
* isn't zero.
*/
SDL_bool result = ( SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit ) ? SDL_TRUE : SDL_FALSE;
//return SDL_SubsystemRefCount[subsystem_index] == 1 || SDL_bInMainQuit;
return result;
Code:
src/SDL.c:84:12: error: cannot initialize return object of type
’SDL_bool’ with an rvalue of type 'bool’
return (SDL_SubsystemRefCount[subsystem_index] == 0);
Just a guess here, but maybe compile with “-std=c99” ?
I think it’s Apple’s LLVM pretending to be a GCC. Crazy system… but
that’s what I have.
It does that, but it’s the “-std=c++11” that’s causing you problems;
you’re compiling C code as C++. You probably shouldn’t do that even if
it mostly seems to work.