Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

NetCraft
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?

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

NetCraft
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?

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

NetCraft
In reply to this post by NetCraft
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
}

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

NetCraft
In reply to this post by NetCraft
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;
}

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

Ryan C. Gordon
In reply to this post by NetCraft

> 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
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Failed to compile SDL2 with GCC 5.3.0/6.2.0 (SDL_bool prob)

Ryan C. Gordon
In reply to this post by NetCraft

> 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
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...