why extern changes mangling to C?

59 Views Asked by At
const unsigned abc = 5;
$ g++ -c -o ec.o ec.cpp
$ nm ec.o 
0000000000000000 r _ZL3abc

So far so good: abc has C++ mangling.

Now:

extern const unsigned abc;
const unsigned abc = 5;
$ g++ -c -o ec.o ec.cpp
$ nm ec.o 
0000000000000000 R abc

Mangling changed to C... Then:

extern "C++" const unsigned abc;
const unsigned abc = 5;
$ g++ -c -o ec.o ec.cpp
$ nm ec.o 
0000000000000000 R abc

Mangling is still C, even though I explicitly asked for C++ one. Why that happens?

0

There are 0 best solutions below