RE: [AD] END_OF_MAIN, again

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


int main(int) is non-standard. The standard allows for types of main:
int main(void) and int main(int, char**).
 
On some systems, main() may have more arguments (the number can be arbitrary), but those declarations of main must be of the second form first, and then have the follow-in parameters.


From: alleg-developers-admin@xxxxxxxxxx [mailto:alleg-developers-admin@xxxxxxxxxx] On Behalf Of Hrvoje Ban
Sent: Wednesday, August 10, 2005 11:09 AM
To: alleg-developers@xxxxxxxxxx
Subject: Re: [AD] END_OF_MAIN, again

On 8/10/05, Chris <chris.kcat@xxxxxxxxxx> wrote:
But the user won't be declaring _mangled_main as extern "C", so it'll still be
a regular C++ symbol.

But if you have extern "C" in declaration, and user make function with same signature (name + arguments) compiler will use C linking for it. 

And you'd need three, if not four, cppmain.cpp files.

int main()  C++ symbol
int main(int argc) Why would someone this, is it in standard ?
int main(int argc, char **argv); // C symbol (via extern "C")
int main(int argc, char **argv, char **argz); // Not supported by allegro's _WinMain

I had this idea:

alwin.h: define main = _mangled_main, install_allegro to use _force_main_linking, extern "C" _mangled_main(int, char **) C++ only
wmain.c: have WinMain call _mangled_main (C symbol)

This will cover C's main(void), main(int, char **) and C++'s main(int, char **). About C++'s main(void) it can be solved in two ways: C++ source with dummy _mangled_main or by forcing user to use main(int, char **) when programming in C++.


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