AW: c++ symbol name

Kaul, Martin martin.kaul@leuze.de
Tue Mar 29 09:02:00 GMT 2005


> Von: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]Im
> 
> Hello,
> I need to define a specific symbol name for a function in the 
> resulting 
> object file. example:
> 
> test.cpp:
> 
> int test();
> 
> int test()
> {
> 	//do something
> 	return 0;
> }
> 
[...]
> 
> So here comes my question. How can I define the symbol name for the 
> test() function for example to _test?
This sounds like you want to mix C++ and C Code. If you only want to rename test() to be able to call test from a C-Modul then you can put the declaration of test() into an extern "C" block. Then the C++ compiler knows that he have to use the C-naming convention.

extern "C"
{
  int test();
}

int test()
{
  //do something
  return 0;
}

Using code above test() internal will be named to _test.

regards
  Martin



More information about the Gcc-help mailing list