We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 215 - [patch] add calling convention specifier SDLCALL for callback functions
Summary: [patch] add calling convention specifier SDLCALL for callback functions
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 1.2
Hardware: x86 Windows (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks: 216
  Show dependency treegraph
 
Reported: 2006-05-06 16:28 UTC by Marc Peter
Modified: 2006-05-06 23:40 UTC (History)
1 user (show)

See Also:


Attachments
proposed patch for fixing calling convention of functions used as callbacks (18.35 KB, patch)
2006-05-06 16:34 UTC, Marc Peter
Details | Diff
fix 'testgl: OpenGL error: 1280' error given by testgl.exe (18.80 KB, patch)
2006-05-06 18:10 UTC, Marc Peter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Peter 2006-05-06 16:28:20 UTC
The current SVN trunk is missing the SDLCALL specifier at numerous locations.

It has to be added for all (possibly user provided) callbacks.

I stumbled over this while creating a makefile for the OpenWatcom compiler for Win32.
Comment 1 Marc Peter 2006-05-06 16:34:54 UTC
Created attachment 111 [details]
proposed patch for fixing calling convention of functions used as callbacks

This patch fixes the calling convention mismatch errors reported by the Open Watcom compiler, as the file name 'sdl-watcom.patch' suggests.

It is needed to build SDL and the tests for Win32 as either a static or dynamic link library on Win32 in Debug as well as in Release mode. The Watcom-Win32 makefile will be delivered separately.
Comment 2 Marc Peter 2006-05-06 16:55:02 UTC
I forgot to mention that this patch also contains the following fixes:
- update include/SDL_config_win32.h with #defines ala HAVE_STRLCPY for
  OpenWatcom
- include <malloc.h> for alloca()
- fix test/testlock.c to not call raise() in the SIGINT handler
  (Calling any C runtime function except abort(), _Exit() and signal()
  in a signal handler exercises undefined behavior - this rules out raise().)
- change src/main/win32/SDL_win32_main.c:
  + remove __cdecl specifier from cleanup_output() because it is passed to
    atexit() and therefore needs to have the compiler's default calling
    convention
  + add SDL_Quit_Wrapper() to be used with atexit() instead of SDL_Quit() for
    the same reason
Comment 3 Marc Peter 2006-05-06 18:10:24 UTC
Created attachment 112 [details]
fix 'testgl: OpenGL error: 1280' error given by testgl.exe

I had missed one calling convention specifier in src/video/wincommon/SDL_wingl.c
in the first patch.

Functions from opengl32.dll are exported using the WINAPI calling convention.
Comment 4 Sam Lantinga 2006-05-06 23:40:54 UTC
I added your patch to subversion, minus the changes to SDL_config_win32.h.
SDL is designed to be built with only MSVCRT.DLL dependencies, to minimize the external C runtime dependencies.