BCB中编译的动态库,为什么函数导出表中的函数名开头都有一个下划线呢?

acqy 2005-07-29 08:52:43
例如:
extern "C" __declspec(dllexport) int Add2(int x, int y)
{
return x+y;
}

但是我用VS的dumpbin命令查看生成的DLL时,函数表中所有函数前面都有一个下划线。比如上面的函数在导出表中就是“_Add2”,为什么呢?
...全文
302 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
僵哥 2005-07-30
  • 打赏
  • 举报
回复
声明为__stdcall就好了
extern "C" _declspec(dllexport) int _stdcall RegisterDll(PChar File,bool Register)
xili 2005-07-30
  • 打赏
  • 举报
回复
用vc的工具吧, 对准dll做一下,生成一个新的 lib
acqy 2005-07-29
  • 打赏
  • 举报
回复
我LoadLibrary以及GetProcAddress的时候岂不是也要加这个下划线?
acqy 2005-07-29
  • 打赏
  • 举报
回复
有没有办法去掉这个下划线?
FengSC 2005-07-29
  • 打赏
  • 举报
回复
正常正常,这是标准C的语法,是一种约定
Waiting4you 2005-07-29
  • 打赏
  • 举报
回复
加个__stdcall再试试
1)VsDll为vs2010工程,编译生成动态库。 2)BCBCall为bcb工程,调用动态库 3)Viewdll.exe为查看DLL导出文件的工具。 注意事项一: VSDll里面有一个 KpHttps.def LIBRARY "KpHttps" EXPORTS InitKpHttp Project > Properties... > Linker > Input > Module Definition File 里面加入你刚才的KpHttps.def文件,重新编译就行了。出来的InitKpHttp函数前面没有下划线,后面没有@8或者@ABCDEF之类的。 注意事项二: 用C++Builder的implib工具生成DLL对应的lib文件。如:implib xx.lib xxx.dll。 生成lib文件之后,C++Builder便可以使用这个lib文件了。 注意事项三: 文件头的声明应该完全一样,否则(呵呵),会出现链接错误。 #ifdef DLL_API #define DLL_API extern "C" _declspec(dllexport) #else #define DLL_API extern "C" _declspec(dllimport) #endif #ifdef __cplusplus extern "C" { #endif DECLDIR int __stdcall InitKpHttp(void); DECLDIR int UnInitKpHttp(void); DECLDIR int KpHttpRequest(char *strurl,char *strhost,char *strresult,int &resultle;); DECLDIR int KpHttpsRequest(char *strurl,char *strhost,char *strresult,int &resultle;); DECLDIR int KpHttpPost(char *strurl,char *strhost,char *strPost,int postlen,char *strresult,int &resultle;); DECLDIR int KpHttpsPost(char *strurl,char *strhost,char *strPost,int postlen,char *strresult,int &resultle;); DECLDIR int KpUpLoadFile(char *strurl,char *strhost,char *filebuf,int filelen,char *strresult,int &resultle;); DECLDIR int KpDownLoadFile(char *strurl,char *strhost,char *filebuf,int &filelen;,char *strresult,int &resultle;); #ifdef __cplusplus } #endif

13,871

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧