Search code examples
c++visual-c++sdlsdl-2

SDL_Log doesn't seem to support %g and %e specifiers


I'm using SDL 2.0.12 with Visual Studio 2013, and I'm seeing this:

SDL_Log("%f", 1.0); // fine
SDL_Log("%g", 1.0); // no luck; prints blank line

Do I need to switch to a newer/older version of SDL or something?


Solution

  • SDL_Log delegates to SDL_vsnprintf. There are three possibilities:

    #if defined(HAVE_LIBC) && defined(__WATCOMC__)
    

    This seems to check for the Watcom C compiler. Not for you.

    #elif defined(HAVE_VSNPRINTF)
    

    This case delegates to your compiler's implementation of vsnprintf if that symbol was defined at compilation time. VS2015 appears to have the %g specifier, I assume VS2013 as well. You can check this yourself trivially.

    #else
    

    I think you are in this situation.
    This uses a custom implementation in SDL. This indeed lacks support for the %g modifier, but you could add it yourself (and submit a pull request).