Re: [AD] Magic main in Windows |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Monday 02 August 2004 11:43, Sam Hocevar wrote:
> 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)
Interesting. How widely supported is this? From the look and general
usefulness, I'd suspect it to be a GNU extension. If both GCC and MSVC
support this, that would be great.
This (probably) leaves compilers like BCC and Watcom in the dark though
(but how many people actually use Allegro with those?)
Evert
>
> 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.