C++ – name mangling with def file and extern “C”

comvisual-c++-2008

I'm creating a basic COM component so I can practice creating them.

I'm exporting DllRegisterServer, DllUnregisterServer,DllGetClassObject and DllCanUnloadNow from a .def file with the PRIVATE keyword(I think Microsoft requires it).

Anway, I specified all 4 functions with extern "C" and yet I'm still getting mangling.
Here is my .def:

EXPORTS
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE

Here is the mangling from dumpbin /EXPORTS

_DllCanUnloadNow@0
_DllGetClassObject@12
_DllRegisterServer@0
_DllUnregisterServer@0

I know the extern "C" helps, because I get really bad mangling without it, but I thought the .def with extern "C" was supposed to get rid of name mangling?

My compiler is VC++ Express 2008.
Linker Command Line:

/OUT:"G:\Programming\COM\BasicMathCOM\BasicMath\Release\BasicMath.dll" /INCREMENTAL:NO /NOLOGO /DLL /MANIFEST /MANIFESTFILE:"Release\BasicMath.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"g:\Programming\COM\BasicMathCOM\BasicMath\Release\BasicMath.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

+/DEF:BasicMath.def, which I had added under additional options.

Best Answer

Are you actually using the .def file?

Can we see your command line to compile?

Related Topic