This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AW: c++ symbol name


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]