Re: [AD] Magic main in Windows

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


On Mon, Aug 02, 2004, Evert Glebbeek wrote:

> The problem is the number of possible ways main can be defined. We don't 
> know if we're dealing with main(int, char **)  or main(void).

   Most compilers support variadic macros nowadays, so we could use
something like that:

   #define main(a,b...) \
      _mangled_main(a,##b); \
      int main(int argc, char *argv[]) \
      { \
         int (*real_main) (int, char*[]) = \
            (int (*) (int, char*[])) _mangled_main; \
         __crt0_argc = argc; \
         __crt0_argv = argv; \
         return (*real_main)(argc, argv); \
      }; \
      int _mangled_main(a,##b)

   This does not require END_OF_MAIN, and works whatever the definition
of main. It requires that main() is not prototyped after <allegro.h> has
been #included, though.

-- 
Sam.




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