[SDL] Bug: Compiling SDL apps
John Silicon
jsilicon at earthlink.net
Tue Feb 14 13:17:31 PST 2006
Sam Lantinga wrote:
>> If it has been broken, I'm not familiar enough Cygwin's build tools to
>> give an exact way to fix it, but my gut wants me to ask if there is any
>> /clean/ way to detect the difference between `c` and `c++` and force c++
>> (from SDL's .h files) to treat make SDL_main compile with C naming
>> conventions?
>>
>
> Does this work?
>
> #define main __cdecl SDL_main
>
> -Sam Lantinga, Senior Software Engineer, Blizzard Entertainment
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>
>
>
No, it won't work, and won't even compile (atleast in any compiler I
have on hand, that is) -- "int main(...)" would become "int __cdecl
main(...)", which is not in the correct order for those words. Wouldn't
work because __cdecl only affects the way the arguments are handled --
not the way C++ mangles names.
After actually looking at the source in SDL_main.h (from 1.2.9), it
seems there actually is a comment in there about having to use the
`extern "C"` jiggies in there:
/* The application's main() function must be called with C linkage,
and should be declared like this:
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[])
{
}
*/
This strikes me as odd -- I don't think I've ever actually had to use it
before -- but, then, I've been using different compilers than those the
original poster is -- perhaps they're smart enough to realize that since
the previous definition of SDL_main is marked `extern "C"` that it
should also be `extern "C"`d.
- Silicon
More information about the SDL
mailing list