[SDL] sdlmain

Peter Mackay mackay.pete+gmane at gmail.com
Tue Jul 4 11:33:19 PDT 2006


I've never really studied the SDLmain implementation - I've just put up with 
it. I would however like to get rid of it, just for the sake of having one 
less library to link to.

How much of SDLmain could be moved into SDL_Init()?

If all you want to do is get rid of WinMain, with my own projects under VC++ 
Express, I've found that you can implement in a shared library a WinMain of 
your own, which just calls the user's main() with a converted argument list. 
No "#define main sdlmain" required.

Having both functions defined works as expected:
- If the user is building a console app, the main() is executed, and 
WinMain() ignored.
- If the user is building a GUI app, the main() is called by WinMain().

i.e. a standard "main", regardless of build type.

I'd love it if such a thing were possible on all platforms/compilers, but I 
don't have the experience to know. It could have the same problem as SDLmain 
under mingw.

Pete

"Ryan C. Gordon" <icculus at icculus.org> wrote in message 
news:44AAA15A.6050401 at icculus.org...
>
>> 6) If hijacking 'main' is required (maybe BeOS), then do it. But in case
>> where it brings nothing special (in current svn SDL 1.3 it often just
>> does commandline arg parsing!), then remove it completely!
>
> It's meant to give you a standard "main" function, as opposed to
> WinMain. If mingw provides this, then you shouldn't need SDL_main on
> that platform.
>
> --ryan. 







More information about the SDL mailing list