For avoid warnings I create main function without name parameters, but
then, SDL doesn’t found main function at link.
El dj, 28-02-2002 a las 14:24, David Leimbach escribi?:
What is the problem? Is there one?On Thursday, February 28, 2002, at 03:50 AM, samsaga2 wrote:
> When I create the main function without args names for avoid warnings
> of unused parameters compilers tell me undefined reference to SDL_main
>
> int main(int, char **)
> {
> ...
> }
>
> I can solve the problem using main(int argc, char **argv) but warnings
> not are my friends.
_______________________________________________
SDL mailing list
SDL at libsdl.org
I believe the problem is that he wants to be able to declare main() as
int main (void) or something; but no, you can’t do that because your
main() function is actually wrapped by SDL. When you run your SDL
program, the first routine run is not your main(), but SDL’s - it then
calls yours, which has to be defined as int main (int, char **) for it
to be able to find it. It’s done like this so that platform-specific
initialisation can be taken care of for you in a transparent fashion.
So the answer is… too bad. Make some sort of trivial usage out of argc
and argv if the warnings bother you. Very few programs don’t process any
command line arguments; in the UNIX world it’d be unthinkable
Maybe even just add a command line flag “/debug” or something that
enables the output of ridiculous amount of debugging information. It’ll
probably come in handy one day down the track - and in the meantime
you’ll have solved your “problem” :-)On Thu, Feb 28, 2002 at 07:24:24AM -0600, David Leimbach wrote:
On Thursday, February 28, 2002, at 03:50 AM, samsaga2 wrote:
When I create the main function without args names for avoid warnings
of unused parameters compilers tell me undefined reference to SDL_main
int main(int, char **)
{
? …
}
I can solve the problem using main(int argc, char **argv) but warnings
not are my friends.
SDL_Main needs to match the function signature with these
parameters.
Please don’t ever code things like
void main (void)
main (void)
main ()
int main (void)
or any permutation of the above.
the two correct versions of main are and have always been:
int main ()
and
int main (int argc, char * argv [])
If you do anything else you shouldn’t expect it to work as nothing else has ever been standard C or C++ for
that matter.
When I create the main function without args names for avoid warnings
of unused parameters compilers tell me undefined reference to SDL_main
int main(int, char **)
{
? …
}
I can solve the problem using main(int argc, char **argv) but warnings
not are my friends.
What is the problem? Is there one?
I believe the problem is that he wants to be able to declare main() as
int main (void) or something; but no, you can’t do that because your
main() function is actually wrapped by SDL. When you run your SDL
program, the first routine run is not your main(), but SDL’s - it then
calls yours, which has to be defined as int main (int, char **) for it
to be able to find it. It’s done like this so that platform-specific
initialisation can be taken care of for you in a transparent fashion.
So the answer is… too bad. Make some sort of trivial usage out of argc
and argv if the warnings bother you. Very few programs don’t process any
command line arguments; in the UNIX world it’d be unthinkable
Maybe even just add a command line flag “/debug” or something that
enables the output of ridiculous amount of debugging information. It’ll
probably come in handy one day down the track - and in the meantime
you’ll have solved your “problem”
FYI, int main(int, char **) should have the same signature as
int main(int a, char **b)
The fact that it doesn’t makes me wonder what’s happening with
your compiler…
See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment
I'll post my empty project tomorrow morning ;)
+ Makefile ;)
I wish this will help ;)
( I'll be DAD!!!! So I don't have plenty of times
theses days.... )
Well, if you look at the code, you’ll see they redefined main to SDL_main… It’s also written in the doc if I remember correctly.
Anyway, having warnings is not necessarly a bad thing, as long as you take the time to verify their meanings…
Toxic Avenger----- Original Message -----
From: samsaga2
Newsgroups: loki.open-source.sdl
To: Lista de SDL
Sent: Thursday, February 28, 2002 4:50 AM
Subject: [SDL] SDL_main error
When I create the main function without args names for avoid warnings of unused parameters compilers tell me undefined reference to SDL_main
int main(int, char **)
{
…
}
I can solve the problem using main(int argc, char **argv) but warnings not are my friends.