Skip to content

Commit

Permalink
Progress fixing bug 4100 - errors and warnings after changeset 11917
Browse files Browse the repository at this point in the history
Ozkan Sezer 2018-03-02 20:02:37 UTC
http://hg.libsdl.org/SDL/rev/d702b0c54e52 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.
  • Loading branch information
slouken committed Mar 3, 2018
1 parent e9b29ed commit 2419d26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/SDL_assert.c
Expand Up @@ -120,13 +120,13 @@ static void SDL_GenerateAssertionReport(void)
}


static SDL_NORETURN void SDL_ExitProcess(int exitcode)
static void SDL_ExitProcess(int exitcode)
{
#ifdef __WIN32__
/* "if you do not know the state of all threads in your process, it is
better to call TerminateProcess than ExitProcess"
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
TerminateProcess(GetCurrentProcess(), exitcode);
/* "if you do not know the state of all threads in your process, it is
better to call TerminateProcess than ExitProcess"
https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
TerminateProcess(GetCurrentProcess(), exitcode);

#elif defined(__EMSCRIPTEN__)
emscripten_cancel_main_loop(); /* this should "kill" the app. */
Expand All @@ -138,7 +138,7 @@ static SDL_NORETURN void SDL_ExitProcess(int exitcode)
}


static SDL_NORETURN void SDL_AbortAssertion(void)
static void SDL_AbortAssertion(void)
{
SDL_Quit();
SDL_ExitProcess(42);
Expand Down
1 change: 1 addition & 0 deletions src/video/windows/SDL_windowsmessagebox.c
Expand Up @@ -560,6 +560,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
TaskConfig.cButtons = messageboxdata->numbuttons;
pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
TaskConfig.nDefaultButton = 0;
nCancelButton = 0;
for (i = 0; i < messageboxdata->numbuttons; i++)
{
pButton = &pButtons[messageboxdata->numbuttons-1-i];
Expand Down
2 changes: 1 addition & 1 deletion src/video/windows/SDL_windowstaskdialog.h
Expand Up @@ -20,7 +20,7 @@
*/
#include <pshpack1.h>

typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR lpRefData);
typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);

enum _TASKDIALOG_FLAGS
{
Expand Down

0 comments on commit 2419d26

Please sign in to comment.