[…]
but i found nothing that tells me i should do this. should i? have i
guessed wrong? looking at it… it seems like the way to go. is this
something that should be added to the SDL doc/FAQ? i haven’t found it
written anywhere, apart from in the FAQ where it says:
"You should be using main() instead of WinMain() even though you are
creating a Windows application…"
http://www.libsdl.org/faq.php?action=listentries&category=4#48
and also in all of the SDL Doc project documentation, it implies that i
should be using main… but i was getting problems with reading the
arguments when i was writing my project just using a main(int argc, char
*argv[]) in windows (i’m pretty sure… it was a few months ago
that i i last touched that bit, though), through mingw.
If you look at the contents of the header SDL_main.h, you will find this
line:
#define main SDL_main
If the file which contains main happens to include SDL.h or SDL_main.h, it
will work fine. Now this means you only need SDLmain in Win32 and MacOS,
but if you name the function SDL_main instead you can link the static lib
in any application on any platform. This is what I’ve been suggesting to
everyone who brings this up lately. =)
main should work though, as long as the right header is included.
there seems to be something in the SDL main headers something that
defines SDL_main as main or something, which appears might allow for
this, but i didn’t really see how it would work.
ok well… any light anyone can shed on the situation would make me
very happy.
Let’s try this one out, shall we?
Case #1:
MacOS with SDLmain, your code has main ()
- The main redefinition in SDL_main.h applies
- main in your code is redefined SDL_main
- SDLmain calls SDL_main after initializing QuickDraw
Case #2:
Win32 with SDLmain, your code has SDL_main ()
- The main redefinition in SDL_main.h applies
- You don’t have a main to redefine
- SDLmain calls SDL_main after registering the application with Win32
Case #3:
Linux without SDLmain, your code has main ()
- SDL_main.h doesn’t apply any redefinitions
- main just works.
Case #4:
Linux with SDLmain, your code has main ()
- SDL_main.h doesn’t apply any redefinitions
- SDLmain.a’s main gets overridden by yours because the linker decides
your version is the one you want
- Everything works, but probably this is a bad thing to depend on…
Case #5:
Linux with SDLmain, your code has SDL_main ()
- SDL_main.h doesn’t apply any redefinitions
- SDLmain.a’s main calls SDL_main in your code
- Everything works, and if ever some platform was added which needed
SDLmain, your code already uses it everywhere. You’re future
brain-damage proof. =)
Hopefully that explains how it works more?On Sat, May 25, 2002 at 09:17:48AM +0100, William Robinson wrote:
–
Joseph Carter Certified free software nut
knghtbrd: are you there?
I’m not sure - let me go ask me.
Yeah, I said that I’m here. =)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020525/495bd572/attachment.pgp