The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)
NetCraft


Joined: 22 May 2016
Posts: 15
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;


Does anybody know how to solve it?
NetCraft


Joined: 22 May 2016
Posts: 15
Oh sorry. That was NOT gcc. I compile SDL with the params:

Code:
$ g++ -std=c++11 -g -Wall SDL.c


But when I get a version of that G++ I get following:
Code:
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I think it's Apple's LLVM pretending to be a GCC. Crazy system... but that's what I have.

Any ideas?
NetCraft


Joined: 22 May 2016
Posts: 15
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
}
NetCraft


Joined: 22 May 2016
Posts: 15
Well. I've written some little patch Smile

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;
}
Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)
Ryan C. Gordon
Guest

Quote:
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" ?

--ryan.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)
Ryan C. Gordon
Guest

Quote:
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" ?

--ryan.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)
Ryan C. Gordon
Guest

Quote:
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.

--ryan.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org