|
From: Max H. <ma...@qu...> - 2002-12-07 00:43:54
|
At 1:24 Uhr +0100 07.12.2002, Serge van den Boom wrote: >On Thu, 5 Dec 2002, Max Horn wrote: >> On OSX, starcon2.c *MUST* #include <SDL.h>. >> >> The reason is that before the normal main(), a special SDL provide >> main must be run, to setup various things, and run a Cooca runloop >> (feel free to ask for details, I wrote a good part of that code :-). >> To this end, SDL.h has a #define main SDL_main in it. >> >> The simple fix is to insert >> #include <SDL.h> >> into starcon2.c. I hope this breaks no other system (in fact I don't >> see why it should). >I will commit this, as there seems to be no other choice. >I would have liked to keep SDL and the main program seperate. >I don't see why SDL even does it that way; a library can itself arrange >for an initialisation function to be called before main(). At least using >gcc, but other compilers probably too. That's not enough in this case, though, we have to be able to call the actual main function, and clean up after it, too. Providing __init / __fini symbols wouldn't work: first off, the order of their calls would then have to be precisely right. Secondly, before we can call the "real" main, we have to call into the OS, and let the OS main runloop take over. Which will then in turn call an object we created, which in turn invokes the application's main method in a callback... If you think this sounds rather nasty, you are right. But the relatively modern event system of Cocoa is simply very different from the more simplistic model used in SDL, so we have to bend a lot to get a match. Max -- ----------------------------------------------- Max Horn Software Developer |