The standard does not address implementation details. There are many,
many things which depend on the implementation, and which prevent
programs from working together: how the classes are laid out, the
structure of the vtable
, etc. In general, compilers will change the
name mangling if they change any of these. This is intentional, as it
prevents code which would not work from linking.
It is possible for a given platform to define a C++ ABI; all compilers
which adhere to it would use compatible implementations, and have a
common name mangling. This is an issue for the platform vendors,
however; for whatever reasons, very few vendors have defined a C++ ABI.
And the reason extern "C"
works is because almost all platforms define a C ABI.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…