Re: [AD] END_OF_MAIN removal patch for msvc

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


On 2008-11-18, torhu <torhu.lists@xxxxxxxxxx> wrote:
> Peter Hull wrote:
> > On Mon, Nov 17, 2008 at 11:40 AM, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:
> >> On 17 Nov 2008, at 03:24, Peter Hull wrote:
> >> Aha! So we could get rid of it on Leopard but not on Tiger? That's a
> >> bit useless if you're trying to compile a program that works on both
> >> (and we should not drop support for Tiger)... was it tested? I could
> >> (when I find the time) test it on my MacBook.
> > The ucontext stuff was added for Leopard AFAICS. So we'd just have to
> > implement a subset of that functionality for ourselves. I think it's
> > covered under the open source darwin bit so we could look to see how
> > it is actually implemented in Leopard (might clang the licence if we
> > copied it directly though), or there is this
> > http://swtch.com/libtask/
> > which is under the MIT license, and  has been used in various
> > libraries here and there.
> > 
> > However this whole approach is a bit hackish (e.g. debugging would be
> > confusing, I guess).
> 
> I guess we could do what END_OF_MAIN does with a macro like the below, 
> if that's better.

Like Evert, I don't think that's better.  It's been rejected before, I
think, multiple times.

It might be best just to expose the boilerplate to the user.
For any program which wants to be portable to Mac OS X, you'd write:

    int real_main(int argc, const char *argv)
    {
	al_init();
	...
    }

    int main(int argc, const char *argv)
    {
	return al_run_in_main_thread(real_main, argc, argv);
    }

Nothing up the sleeves.

We might need three different versions of al_run_in_main_thread,
for zero arguments, two arguments, and three arguments.  Of course, we'd
probably get sick of writing that and end up providing a macro:

    ALLEGRO_MAIN_WRAPPER(real_main, argc, argv);

which looks suspiciously like END_OF_MAIN().  *But* it doesn't require
the symbol `_mangled_main_address' to exist, which causes problems when
people try to load the Allegro shared object at run-time, and there is
no name mangling.

Peter





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