WinMain and SDLMain.lib

Hi all !

I have a question here. Wouldn’t it make sense, to put everything in
SDLMain.c into SDL.c, while if one uses SDL.dll, he/she will definitly need
to call SDL_Init once. So I do not see any problems in compiling the WinMain
function provided with SDLMain into SDL.dll. This is just like e.g. QT or
MFC does with the WinMain function.

This might help to
a) need no static linking here, everything is in one .dll
b) lower the rate of faq related questions about the WinMain / main function
on this list
c) make SDL become more consitent

Regards,

Sascha

“Sascha G?nther” <s.guenther at lives.de> wrote

I have a question here. Wouldn’t it make sense, to put everything in
SDLMain.c into SDL.c, while if one uses SDL.dll, he/she will definitly need
to call SDL_Init once. So I do not see any problems in compiling the WinMain
function provided with SDLMain into SDL.dll. This is just like e.g. QT or
MFC does with the WinMain function.

sascha, this doesn’t work and i’ll tell you why. on windows there are
some initialization functions that NEED to happen in the main executable
(not in a DLL). SDLmain gets around the problem by linking some critical
init functions inside you executable. there is a similar situation on
macos as well for initializing quicktime.

at one point i tried several workarounds to make this happen, but it
never really worked correctly. perhaps in the 'all things to everyone’
release of SDL-2.0 it can be cleaned up a bit further. some kind of
SDL_PreInit() function which is really a #define macro to call all
the right functions.

Pete Shinners wrote:

“Sascha G?nther” <s.guenther at lives.de> wrote

I have a question here. Wouldn’t it make sense, to put everything in
SDLMain.c into SDL.c,

sascha, this doesn’t work and i’ll tell you why. on windows there are
some initialization functions that NEED to happen in the main executable
(not in a DLL).

I have a standalone library for the WinMain problem:
http://www.HardcoreProcessing.com/pro/winmain/index.html

Maybe this will be useful. It is inspired by the way SDL
handles the WinMain problem, but it is completely separate -
so it doesn’t depend on anything. But I’m not sure it will
work for SDL.

I was lazy when writing this, so it doesn’t free up the
memory for the command-line arguments - but WinMain should
only be called once, so it’s not a huge problem :slight_smile:

Cheers–
http://www.HardcoreProcessing.com