Possible Duplicate:
Why do we need extern “C”{ #include <foo.h> } in C++?
many a times in our code i have seen some statements like following:
extern "C" {
//some code
开发者_StackOverflow };
what does this exactly mean?
It tells the C++ compiler that "some code" must be compiled in C style. This allows the linkage between C and C++ code.
It tells the compiler to treat the following code as C code and not as c++ code
More to the point, functions with C++ linkage will not be found by the linker when called from a C function unless you specify that the functions should have the same linkage type. So you'll get all sorts of link errors, which won't seem obvious as to why.
精彩评论