#ifdef __cplusplus

#ifdef __cplusplus
extern “C” {

what does this do?

If you are writing a DLL, C++ will mangle the names of any exported functions. It does this to allow overloading.

The converse is true if you are importing functions into C++ from a C DLL or from a C++ DLL that was exported with the extern “C”.

If you don’t put the extern “C” on the prototypes of the imported functions, C++ assumes you are importing the mangled names, yet the DLL is exporting non-mangled names, so it will not be able to find it.

Hope that makes sense.

Close, but not quite. This is necessary when calling C functions from C++ code. It has nothing to do with DLLs. Like you said, it is because of name mangling. DLL stands for Dynamic-Link Library, if you didn’t know.

Ok, so my description wasn’t technically accurate, but it is the most common example of where it is used. This is also something that you find in static libraries. Also, since libraries are usually where you are going to use C functions in C++, it really isn’t inacurate to describe how it’s used in regard to DLLs.