From: Greg C. <gch...@sb...> - 2010-10-28 15:09:18
|
On 2010-10-28 13:24Z, Andrea Galeazzi wrote: > Tor was right, I used g++ -e __Z12OmegaStartupv and it works. Now the > question is: do I to inspect the object file in order to know which > symbol must be specified to the -e linker option? It sounds me very > strange... '__Z12OmegaStartupv' is a "mangled" name. C++ functions can be overloaded, e.g.: void f(); int f(char *); The C++ compiler can figure out which one to call in any context, but those two functions must have different names in the object file--they can't both be called simply 'f'--so their signatures are encoded into "mangled" names. All C++ compilers do this. And they deliberately do it in mutually incompatible ways, for safety: http://www.mingw.org/wiki/MixingCompilers Even different versions of the same compiler may treat mangling differently. In situations like yours, it would be easier and more robust to have one simple name. That's why C++ provides 'extern "C"'. If you write extern "C" void f(); then f()'s name will not be "mangled"--it will be the same name that the compiler would use for this function: void f(void); in a C program. That name is '_f', prefixed with '_' because that's the normal convention for C linkage, for all compilers on this platform. |