[AD] New END_OF_MAIN() Proposal

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


Note: The email didnt seem to go through the first
time, so I'm sending it again.

I recently came up with an idea that would remove the
need for the phrase END_OF_MAIN() after the user's
'main' function.  It still involves macro magic and
the 'main' function would still need to have 'int'
specified, but this method would pretty it up a little
bit.

For this example I'll use alwin.h's END_OF_MAIN which
is located in
allegro/include/allegro/platform/alwin.h.

Here I'll summarize ruffly how its done now, and then
how I propose it to be done

#define main _mangled_main
#define END_OF_MAIN()                                 
                   
 int __stdcall WinMain(void *hInst, void *hPrev, char
*Cmd, int nShow) { \
 return _WinMain((void *)_mangled_main, hInst, hPrev,
Cmd, nShow); }

int main() {

}
END_OF_MAIN()

Which equates to:

int _mangled_main() {

}
 int __stdcall WinMain(void *hInst, void *hPrev, char
*Cmd, int nShow) {
 return _WinMain((void *)_mangled_main, hInst, hPrev,
Cmd, nShow); }

Now for the method I'd like to propose:

#define main() \
 _mangled_main(); \
 int __stdcall WinMain(void *hInst, void *hPrev, char
*Cmd, int nShow) { \
 return _WinMain((void *)_mangled_main, hInst, hPrev,
Cmd, nShow); } \
 int _mangled_main()

int main() {

}

Which you can guess as to what it equates to.  This
method still has the issue of not being able to
support main() and main(int,char**).  /me curses
non-overloaded macro functions :P.  But I think that
making the user specify one or the other format would
be cleaner then the current system.

Anyway, its not a perfect or even finished solution,
just wanted to suggest it cause it had been bouncing
around in my mind for a while.




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