Re: [AD] Proposal for new magic main

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


> And one more problem is that main can not be used in structs.

Yes.

> END_OF_MAIN() is good (portable and allows to use main as entry
> point), but requires to have real main in some other file.

Portable is not exactly the wording I would use since it breaks on at least
one system... And the very reason for this breakage is the need for this
external main, more precisely the need for this external main *and* the
possibility of disabling it with USE_CONSOLE.

So another solution could be to get rid of USE_CONSOLE under Unices: main
would always be changed into _mangled_main, so that there is never a
duplicated main definition.

> If program entry point supplied by user was not called 'main'
> (e.g. al_main), then END_OF_MAIN macro (or IMPLEMENT_MAIN macro, which
> can be placed anywhere, not only after user supplied main) may have
> instance of main (or WinMain), which calls al_main.

I think imposing two constraints is too much: either al_main() or
END_OF_MAIN(), not both.

> But it would be nice to allow initialization of most parts of Allegro
> without these 'main' tricks, by passing (argc, argv) to allegro_init
> (or al_init_system (argc, argv, ...)), or something like that.

But there is not such argc/argv for GUI apps under Windows. And the magic
main trick is not intended to initialize Allegro, but precisely to provide a
portable executable_name/argc/argv framework to Allegro programmers.

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



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