我在MV C ++ 2012中创建了一个DLL,

Dumpbin /Exports filename


DLL文件内部的函数名称内部带有等号。我必须使用公共语言运行时支持(/ crl),因为我使用了C#中的DLL。这就是为什么函数名称会显示等号的原因?我的头文件:

#ifdef ColorDLL_EXPORTS
#define ColorDLL_API __declspec(dllexport)
#else
#define ColorDLL_API __declspec(dllexport)
#endif

extern "C"{
ColorDLL_API int ColorSelect(int i);
}


ColorDLL.cpp

#include "stdafx.h"
#include "ColorDLL.h"
#using <ColorDiologeClass.dll>

extern "C"{
ColorDLL_API int ColorSelect(){
ColorDiologeClass::Class1::ColorReturn(1);
return 1;
}


}
当我使用Dumpbin时,名称显示如下:

Name
ColorSelect = _ColorSelect


为什么是这样?我希望它显示为ColorSelect,而不是ColorSelect = _ColorSelect。而且,如果我将其保留为这种方式,该如何从需要精确函数名的JMP之类的程序中调用该函数?会是ColorSelect吗?还是ColorSelect = _ColorSelect?

最佳答案

名称为“乱码”-函数的名称包含返回类型和参数。如果您不希望这样做,可以在函数名称前(或函数块周围)使用extern "C"

关于c# - 将外部依赖项添加到C++ DLL文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16866861/

10-13 06:52