I am familiar with the extern keyword, it is used to declare a variable present in some other file, but what does the following statement mean??
extern "C" const IMAGE_DOS_HEADER __ImageBase; It means the __ImageBase global variable uses C linkage and that its name should be mangled using the rules for C instead of C++.
EDIT: It just so happens that Raymond Chen recently published an article that demonstrates my original answer was plain wrong: extern "C" does not disable name mangling, it only changes the rules used to perform it. C names can be mangled too.
extern "C" linkage cannot be assigned to a pointer to a C++ function.It means do not mangle the symbol name __ImageBase that follows the extern "C". In short it ensures you can use the variable in C++ code.
extern "C" specify's the linkage to be applied. In short a Linkage specification.
It tells the C++ compiler to apply linkage of the type of C to the symbol that follows.
Good Read:
Using extern to Specify Linkage
How to mix C and C++
extern "C" is indeed a C++-only construct, but it still means C code that links to the C++ module defining this variable will be able to refer to it... So, it actually works both ways, C to C++ and C++ to C (section 32.6 of the FAQ seems to agree :).extern "C" construct, and so one must wrap the extern "C" { and` }` lines in an #ifdef so they won't be seen by the C compilers.both ways (but I don't know if I was actually clearer this time around :)
IMAGE_DOS_HEADER? Language linkage normally only applies to function types (included nested function types, such as pointer to function).extern "C", I can't even find the name in the object file. Which I definitely don't understand.)