Is SDL supposed to be using WinMain?

Hi there,
i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and am
learning by trial and error in visual studio 2005 as we speak.

i’m stepping into the code from the beginning, and not far into it, i
end up at a file named crtexe.c
and i noticed:

#ifdef WINMAIN
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo;
BOOL inDoubleQuote=FALSE; <-------cursor is on this line.

any idea about wether or not it should be doing this?

I won’t claim expertise on this but I suspect what’s happening is that
winmain() is used but it’s disguised as simple main(). Since SDL has
been developed so as to be portable across multiple systems, it goes
with the C standard of using main() as the entry point. If development
is done in a Windows oriented compiler then main() in the code gets
transformed into winmain() where and when needed.–
Lilith

On 9/7/2007 at 4:00 AM, “malik martin” wrote:
Hi there,
i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and
am
learning by trial and error in visual studio 2005 as we speak.

i’m stepping into the code from the beginning, and not far into it,
i
end up at a file named crtexe.c
and i noticed:

#ifdef WINMAIN
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo;
BOOL inDoubleQuote=FALSE; <-------cursor is on this line.

any idea about wether or not it should be doing this?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

oh, ok. now i understand.
it turns out that that wasn’t the bug anyway. but that’s very
interesting, i’m still a big noob when it comes to #ifndef/#ifdef and
things.On 9/7/07, Lilith Calbridge wrote:

I won’t claim expertise on this but I suspect what’s happening is that
winmain() is used but it’s disguised as simple main(). Since SDL has
been developed so as to be portable across multiple systems, it goes
with the C standard of using main() as the entry point. If development
is done in a Windows oriented compiler then main() in the code gets
transformed into winmain() where and when needed.


Lilith

On 9/7/2007 at 4:00 AM, “malik martin” <@malik_martin> wrote:
Hi there,
i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and
am
learning by trial and error in visual studio 2005 as we speak.

i’m stepping into the code from the beginning, and not far into it,
i
end up at a file named crtexe.c
and i noticed:

#ifdef WINMAIN
_TUCHAR *lpszCommandLine;
STARTUPINFO StartupInfo;
BOOL inDoubleQuote=FALSE; <-------cursor is on this line.

any idea about wether or not it should be doing this?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Last time I used it you needed to include windows.h, in MinGW you need
to link with -lmingw at the start of the list or you get errors about
winmain. Either way, it seems to be a requirement for Windows programs.On Fri, 2007-09-07 at 05:00 -0400, malik martin wrote:

Hi there,
i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and am
learning by trial and error in visual studio 2005 as we speak.


Yahoo! Messenger - with free PC-PC calling and photo sharing. http://uk.messenger.yahoo.com

oh ok. so “all” or maybe most windows programs need thisOn 9/7/07, Paul Duffy wrote:

On Fri, 2007-09-07 at 05:00 -0400, malik martin wrote:

Hi there,
i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and am
learning by trial and error in visual studio 2005 as we speak.

Last time I used it you needed to include windows.h, in MinGW you need
to link with -lmingw at the start of the list or you get errors about
winmain. Either way, it seems to be a requirement for Windows programs.


Yahoo! Messenger - with free PC-PC calling and photo sharing. http://uk.messenger.yahoo.com


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello !

i’m using some code that works with SDL and i get an exception at
runtime that i’m trying to debug. i’m very new to the debugger and am
learning by trial and error in visual studio 2005 as we speak.

Last time I used it you needed to include windows.h, in MinGW you need
to link with -lmingw at the start of the list or you get errors about
winmain. Either way, it seems to be a requirement for Windows programs.

SDL internally needs these system specific main functions.
But SDL uses ways so that the normal coder can use the portable
int main (int argc, char *argv ()] way on most/all OSes.

This thing is in libSDLmain.

CU

i see. I still haven’t really learned much at all about the arguments
in main( int argc, char argv[]) most of my programming books don’t
speak of it. i saw one online that did but i can’t remember the name.
looks like i’ll be needing to read up on that pretty soon though :slight_smile:

thanksOn 9/7/07, Torsten Giebl wrote:

Hello !

SDL internally needs these system specific main functions.
But SDL uses ways so that the normal coder can use the portable
int main (int argc, char *argv ()] way on most/all OSes.

This thing is in libSDLmain.

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

— malik martin wrote:

i see. I still haven’t really learned much at all about the arguments
in main( int argc, char argv[]) most of my programming books don’t
speak of it. i saw one online that did but i can’t remember the name.
looks like i’ll be needing to read up on that pretty soon though :slight_smile:

Command line arguments.

argc is the count for the number of arguments
*argv[] (or **argv) is an array of character arrays containing those
arguments
arg 0 is always the first thing on the command line which is usually
the command itself.

In any good practice main should always return an int, but the
arguments are optional so int main(void) is still valid.____________________________________________________________________________________
Pinpoint customers who are looking for what you sell.
http://searchmarketing.yahoo.com/

Hello !

In any good practice main should always return an int, but the
arguments are optional so int main(void) is still valid.

It is, but when using SDL you should use
the int main(int argc, char *argv []) way,
as SDL needs it.

CU

ok good to remember thanks guys!!On 9/7/07, Torsten Giebl wrote:

Hello !

In any good practice main should always return an int, but the
arguments are optional so int main(void) is still valid.

It is, but when using SDL you should use
the int main(int argc, char *argv []) way,
as SDL needs it.

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org