After having some trouble setting up SDL, I found out that SDL defines a macro that replaces main:
#define main SDL_main
// And then
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
This can also create compilation errors, if the main function doesn't have the argc
and argv
parameters defined.
This macro gives me headaches just when I see it... Why does SDL need to redefine main? After some more searching, I found that some people #undef main
, and use it the normal way.
So this is the question: why does SDL need to redefine main, what does it do? Are there any side effects to undefining it?
One thing I noticed is that SDL redirects standard output and error to files (and I don't want this behavior), and this behavior stops if I undefine main.