Functions in extern "C" are interpreted in C manners, e.g. no name mangling. However, why do C++ features, such as STL, std::string
, smart pointer and so on, can be used in the function definition but cannot be used in the function declaration (to link with other C code)?
For example, I want to use std::vector
in extern "C". As far as I know, if it's used in the implementation, the .obj file will have such instructions to jump to the ctor, etc; if it's used in the prototypes, it should do so too, and there seems to be no difference between them.
Besides, there is a related question for currently I'm studying ABI. What's the relationship between so-called ABI and language linkage in C++? How does ABI influence linking with extern "C" C++ code in C?