Progress fixing bug 4100 - errors and warnings after changeset 11917
authorSam Lantinga <slouken@libsdl.org>
Fri, 02 Mar 2018 22:53:25 -0800
changeset 11920c8b4a5166613
parent 11919 8ebcdaa049e5
child 11921 88a2982221ec
Progress fixing bug 4100 - errors and warnings after changeset 11917

Ozkan Sezer 2018-03-02 20:02:37 UTC
http://hg.libsdl.org/SDL/rev/5ce3f8bf8381 resulted in an error and
two warnings when compiled with mingw.

1. Error from SDL_windowstaskdialog.h:
In file included from src/video/windows/SDL_windowsmessagebox.c:29:0:
src/video/windows/SDL_windowstaskdialog.h:23:54: error: expected ')' before 'HWND'

This is fixed by removing unnecessary annotations:

2. Warning from SDL_assert.c:
src/SDL_assert.c: In function 'SDL_ExitProcess':
src/SDL_assert.c:138:1: warning: 'noreturn' function does return

Indeed ExitProcess() is prototyped with DECLSPEC_NORETURN, but
TerminateProcess() is not. This can be rectified by adding an
exit() call in there. Do NOTE, however, that requires building
with a libc:

3. Warning from SDL_windowsmessagebox.c:
src/video/windows/SDL_windowsmessagebox.c: In function 'WIN_ShowMessageBox':
src/video/windows/SDL_windowsmessagebox.c:513:9: warning: 'nCancelButton' may be used uninitialized in this function

My lazy solution was manually initializing nCancelButton to 0.
src/SDL_assert.c
src/video/windows/SDL_windowsmessagebox.c
src/video/windows/SDL_windowstaskdialog.h
     1.1 --- a/src/SDL_assert.c	Fri Mar 02 22:48:15 2018 -0800
     1.2 +++ b/src/SDL_assert.c	Fri Mar 02 22:53:25 2018 -0800
     1.3 @@ -120,13 +120,13 @@
     1.4  }
     1.5  
     1.6  
     1.7 -static SDL_NORETURN void SDL_ExitProcess(int exitcode)
     1.8 +static void SDL_ExitProcess(int exitcode)
     1.9  {
    1.10  #ifdef __WIN32__
    1.11 -    /* "if you do not know the state of all threads in your process, it is
    1.12 -       better to call TerminateProcess than ExitProcess"
    1.13 -       https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
    1.14 -    TerminateProcess(GetCurrentProcess(), exitcode);
    1.15 +    /* "if you do not know the state of all threads in your process, it is
    1.16 +       better to call TerminateProcess than ExitProcess"
    1.17 +       https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
    1.18 +    TerminateProcess(GetCurrentProcess(), exitcode);
    1.19  
    1.20  #elif defined(__EMSCRIPTEN__)
    1.21      emscripten_cancel_main_loop();  /* this should "kill" the app. */
    1.22 @@ -138,7 +138,7 @@
    1.23  }
    1.24  
    1.25  
    1.26 -static SDL_NORETURN void SDL_AbortAssertion(void)
    1.27 +static void SDL_AbortAssertion(void)
    1.28  {
    1.29      SDL_Quit();
    1.30      SDL_ExitProcess(42);
     2.1 --- a/src/video/windows/SDL_windowsmessagebox.c	Fri Mar 02 22:48:15 2018 -0800
     2.2 +++ b/src/video/windows/SDL_windowsmessagebox.c	Fri Mar 02 22:53:25 2018 -0800
     2.3 @@ -560,6 +560,7 @@
     2.4      TaskConfig.cButtons = messageboxdata->numbuttons;
     2.5      pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
     2.6      TaskConfig.nDefaultButton = 0;
     2.7 +    nCancelButton = 0;
     2.8      for (i = 0; i < messageboxdata->numbuttons; i++)
     2.9      {
    2.10          pButton = &pButtons[messageboxdata->numbuttons-1-i];
     3.1 --- a/src/video/windows/SDL_windowstaskdialog.h	Fri Mar 02 22:48:15 2018 -0800
     3.2 +++ b/src/video/windows/SDL_windowstaskdialog.h	Fri Mar 02 22:53:25 2018 -0800
     3.3 @@ -20,7 +20,7 @@
     3.4  */
     3.5  #include <pshpack1.h>
     3.6  
     3.7 -typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR lpRefData);
     3.8 +typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);
     3.9  
    3.10  enum _TASKDIALOG_FLAGS
    3.11  {