Re: [AD] No need for END_OF_MAIN (Windows) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
This is the approach I use. Still has the issue of
variables called main... What I do is call it MAIN,
maybe that could be the way? Or even AL_MAIN.
--- Evert Glebbeek wrote:
> > So close and yet so far. To bad there is no macro
> overloading, so we
> > could have one for main() and other for main(int,
> char **)
>
> Indeed. I think pretty much all ways to get rid of
> END_OF_MAIN() have been
> explored several times over the past few years
> (including this one) and
> none of them seems doable. Unfortunately.
>
> > I search trough almac.h and alosx.h and only found
> this:
> >
> > > #ifndef ALLEGRO_NO_MAGIC_MAIN
> > > #define ALLEGRO_MAGIC_MAIN
> > > #define main _mangled_main
> > > #undef END_OF_MAIN
> > > #define END_OF_MAIN() void
> *_mangled_main_address =3D (void*)
> > _mangled=
> > _main;
> > > #else
> > > #undef END_OF_MAIN
> > > #define END_OF_MAIN() void
> *_mangled_main_address;
> > > #endif
> >
> > And as I said before didn't find where is
> _mangled_main_address used.
>
> allegro/src/macosx/main.m, I guess. Note that the
> MacOS X problem is a
> different one from Windows.
>
> Evert
--- include/allegro/platform/alwin.h Mon Mar 14 11:29:14 2005 UTC
+++ include/allegro/platform/alwin.h Fri May 13 09:29:47 2005 UTC
@@ -39,8 +39,6 @@
#if (!defined ALLEGRO_NO_MAGIC_MAIN) && (!defined ALLEGRO_SRC)
#define ALLEGRO_MAGIC_MAIN
- #define main _mangled_main
- #undef END_OF_MAIN
/* disable strict pointer typing because of the vague prototype below */
#define NO_STRICT
@@ -49,12 +47,16 @@
extern "C" int __stdcall WinMain(void *hInst, void *hPrev, char *Cmd, int nShow);
#endif
- #define END_OF_MAIN() \
- \
- int __stdcall WinMain(void *hInst, void *hPrev, char *Cmd, int nShow) \
- { \
- return _WinMain((void *)_mangled_main, hInst, hPrev, Cmd, nShow); \
- }
+ #define main(...) \
+ \
+ _mangled_main(VA_ARGS); \
+ \
+ int __stdcall WinMain(void *hInst, void *hPrev, char *Cmd, int nShow) \
+ { \
+ return _WinMain((void *)_mangled_main, hInst, hPrev, Cmd, nShow); \
+ } \
+ \
+ int _mangled_main(VA_ARGS)
#endif