Re: [AD] Darwin/MacOS X port

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


> 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

Don't you mean rather:

AL_FUNC(int, _main, (void *_mangled_main, int argc, char *argv[]));

#if (!defined ALLEGRO_NO_MAGIC_MAIN) && (!defined ALLEGRO_SRC)

   extern int _mangled_main(int argc, char *argv[]);

   #define main                                               \
                                                              \
      main(int argc, char *argv[])                            \
      {                                                       \
         return _main((void *)_mangled_main, argc, argv);     \
      }                                                       \
                                                              \
      int _mangled_main

#endif    ?


I tried that too, but it of course imposes that the user main() be defined
with the right prototype. However, the big advantage is that END_OF_MAIN()
goes away.


> 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.
>    }
>
> [...]
> 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 totally agree (albeit 'int AL_MAIN(int arg, char *argv[])' is more
correct).

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



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