Fixed bug 3323 - SDL_LogOutput prints message twice on Windows when linked with libc
authorSam Lantinga
Sat, 01 Oct 2016 12:28:05 -0700
changeset 10412a644712b2fb2
parent 10411 9012ec687429
child 10413 636499ff46f8
Fixed bug 3323 - SDL_LogOutput prints message twice on Windows when linked with libc

Simon Hug

If SDL2 is compiled with HAVE_LIBC on Windows, the SDL_LogOutput function has two ways of printing a message. WriteConsole and fprintf.
src/SDL_log.c
     1.1 --- a/src/SDL_log.c	Sat Oct 01 12:17:42 2016 -0700
     1.2 +++ b/src/SDL_log.c	Sat Oct 01 12:28:05 2016 -0700
     1.3 @@ -324,7 +324,7 @@
     1.4          size_t length;
     1.5          LPTSTR tstr;
     1.6  
     1.7 -#ifndef __WINRT__
     1.8 +#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
     1.9          BOOL attachResult;
    1.10          DWORD attachError;
    1.11          unsigned long charsWritten; 
    1.12 @@ -356,7 +356,7 @@
    1.13                          stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
    1.14                  }
    1.15          }
    1.16 -#endif /* ifndef __WINRT__ */
    1.17 +#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
    1.18  
    1.19          length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
    1.20          output = SDL_stack_alloc(char, length);
    1.21 @@ -366,7 +366,7 @@
    1.22          /* Output to debugger */
    1.23          OutputDebugString(tstr);
    1.24         
    1.25 -#ifndef __WINRT__
    1.26 +#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
    1.27          /* Screen output to stderr, if console was attached. */
    1.28          if (consoleAttached == 1) {
    1.29                  if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
    1.30 @@ -376,7 +376,7 @@
    1.31                      }
    1.32                  }
    1.33          }
    1.34 -#endif /* ifndef __WINRT__ */
    1.35 +#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */
    1.36  
    1.37          SDL_free(tstr);
    1.38          SDL_stack_free(output);