Re: [AD] END_OF_MAIN removal patch for msvc |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Wed, 2008-11-19 at 10:40 +0000, Peter Hull wrote:
> I'd rather have things out in the open instead of macro magic or some
> weaselly thread hacks. Could we not put the real main in a static lib
> and have the user put their code in allegro_main(). Real main would
> look like
> // For platforms that don't need a separate thread
> int main(int argc, char argv[])
> {
> al_init();
> return allegro_main(argc, argv);
> }
>
> // For platforms that do
> int main(int argc, char argv[])
> {
> al_init();
> store_args_somewhere(argc, argv);
> start_in_new_thread(allegro_main);
> enter_main_loop();
> // Never gets here
> return 0;
> }
>
> This would be OK for the straightforward 'pure' Allegro apps.
>
> Then for the advanced user writing plugins or whatever they'd just
> have to write their own main() function maybe with some help from
> macros like AL_PLATFORM_NEEDS_SECONDARY_THREAD or whatever.
>
> I know Jon Rafkind tried to mate Allegro 4 and Scheme and we just
> couldn't do it on OS X because of the threading issue.
>
I didn't read the whole thread, but I'm all for this solution. The less
magic is going on behind the users back, the better. And if we simply
require users to not have any kind of "main" of their own, things never
can be inadvertently made non-cross-platform.
I'm not completely sure, but I think SDL does it that way for a long
time - they put the different main/Winmain functions into a separate
library, something like sdlmain.so. That way all normal users simply
will link to sdlmain.so which provides the real main() function. Someone
doing things like writing a language binding would provide their own
main() implementation. Really sounds like the ideal thing to do, and
finally my programs no longer will fail to compile under windows and OSX
because I forgot END_OF_MAIN :)
--
Elias Pschernig <elias@xxxxxxxxxx>