Search code examples
gccname-mangling

Is it possible for gcc to name mangle?


I had some code that wasn't working until I added extern "C" before the name of a function, even though I was compiling using gcc. The file's name did, however, end in ".cpp".

Is it possible for gcc to name mangle? Did it intelligently pick up the file extension ".cpp"?


Solution

  • The gcc compiler driver looks at the file extension. If it is .cpp (or .cc, .C and a few more), the file is compiled as a C++ file: