Re: [AD] Magic main in Windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Monday 02 August 2004 09:54, Chris wrote:
> You mean, like the polling functions we have now? ;) Though I know how 
> much everyone /looves/ polling. Perhaps allegro_init() could spawn off 
> into a new thread, continuing the user code where it left off, and in 
> the main thread, do whatever it does now?

There is no guarentee that the user will call allegro_init() from the main 
thread. Considering Allegro's current poor multithreading support, this is 
no much of an issue yet, as the user probably has to do that.
If we want to improve the thread safety of Allegro, then I don't think we 
can assume that.

> I still think using al_main would be best. al_main is an actual, 
> user-created function. Then, Allegro supplies its own main function that 
> calls al_main. So, you'd have this:

I tried doing something like that to the Windows port last night, changing 
main to WinMain. Didn't work, but could have been me just being clumsy.
Personally, I don't like requireing the user to write an al_main() rather 
than a main() function.

As I said, SDL handles this by (always) redefining main() on Windows and 
requiring that it be int main(int, char**). We could get around the 
requirement of having main(int, char**) by using a function pointer and a 
cast (as in src/unix/usystem.c).
The only thing that is unclear to me is if and how the user is able to 
disable Allegro's magic main handling in this case. I got the impression 
that in SDL, you simply can't, but I can't imagine that's right...
SDL's WinMain seems to be in a seperate sourcefile that is (statically?) 
linked to the executable. Allegro's current magic WinMame is created in 
the headerfile from the END_OF_MAIN() typedef.

Evert





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/