Extern "C"


Consider the prototype of a function exported by a DLL:

extern "C" __declspec ( dllexport ) void display ( CDC *p, int i ) ;

Here extern “C” portion declares that display( ) is a standard C function. This ensures that if compiled using a C++ compiler the name of the function would not be decorated by the compiler. If not mentioned, the C++ compiler decorates the function name by adding suitable frills to it depending on the return type and its arguments. If the name gets decorated (or mangled?) then a client program written in C would not be able to access it.