Re: [AD] Darwin/MacOS X port

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


On February 13, 2002 05:37 pm, you wrote:
> Eric Botcazou wrote:
> > Do we hit a fondamental limitation of the C preprocessor, or is there
> > a trick to work around the problem ?
>
> The following kind of works, but it's even ugly to be a preprocessor
> hack and I'm not sure it will work in all possible kinds of situations:
>
>    #define main                                               \
>       int al_mangled_main(int argc, char *argv[]);            \
>       main(int argc, char *argv[])                            \
>       {                                                       \
>          return _main((void *)_mangled_main, argc, argv);     \
>       }                                                       \
>       int _mangled_main
>
>    #define END_OF_MAIN()
>
> IIRC someone on [AL] suggested to get rid of END_OF_MAIN() in 5.0 and
> instead you would have to do
>
>    AL_MAIN(int argc, char *argv[])
>    {
>       int i;
>       allegro_init();
>       etc.
>    }
>
> where in this case I suppose we would have
>
>    #define AL_MAIN(arg1, arg2)                                \
>       int al_mangled_main(arg1, arg2);                        \
>       int main(int argc, char *argv[])                        \
>       {                                                       \
>          return _main(_mangled_main, argc, argv);             \
>       }                                                       \
>       int al_mangled_main(arg1, arg2)
>
> This has the advantage of being more explicit: we don't have to worry
> about the symbol main being defined to something else (in case someone
> does struct{int main;}x; (in case that's more than an academic
> problem)). I don't know all details about END_OF_MAIN() so maybe it
> doesn't work everywhere...

I don't see why we need anything like that. just have an API entry called

int al_main(int argc, char **argv);

which every program calls. And if its not nesesary on a platform it gets
#define'd away.


-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx
http://strangesoft.net



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