Why would you use 'extern "C++"'?
Solution 1:
The language permits:
extern "C" {
#include "foo.h"
}
What if foo.h contains something which requires C++ linkage?
void f_plain(const char *);
extern "C++" void f_fancy(const std::string &);
That's how you keep the linker happy.
Solution 2:
There is no real reason to use extern "C++"
. It merely make explicit the linkage that is the implicit default. If you have a class where some members have extern "C" linkage, you may wish the explicit state that the others are extern "C++".
Note that the C++ Standard defines syntactically extern "anystring"
. It only give formal meanings to extern "C"
and extern "C++"
. A compiler vendor is free to define extern "Pascal"
or even extern "COM+"
if they like.