Re: [AD] END_OF_MAIN, again

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


On Wednesday 10 August 2005 09:09 am, Hrvoje Ban wrote:
> But if you have extern "C" in declaration, and user make function with same
> signature (name + arguments) compiler will use C linking for it.

No it won't. You can have a C function and C++ function using the same name 
and same arguments. Because C and C++ uses different mangling, the linker 
will see them as two different functions. The only problem comes in if you 
declare them both in the same file and try to use it, the compiler becomes 
confused over which one you want.

extern "C" int _mangled_main(int argc, char **argv);

int _mangled_main(int argc, char **argv)
{
   return 0;
}

That's acceptable C++ code, and will leave the C-style _mangled_main 
undefined.

> 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++.

AFAIK, forcing the user to use a specific main type is unnacceptable. 
Especially since it'd break existing programs.




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