__stdcall 名称修饰的语法是什么?
我有一个程序调用一组函数,如下所示:
int _stdcall VB_Create(char*);
int _stdcall VB_Open(unsigned int, unsigned int, unsigned int, unsigned int);
...
...
如果名称装饰不匹配,链接器会显示如下错误:
error LNK2019: unresolved external symbol "int __stdcall VB_Create(char *)" (?VB_Create@@YGHPAD@Z) .....
我的理解是 _stdcall
语法是 ' _' + '函数名称' + '@' + '参数数量 * 4'
。
那么,为什么链接器要求 ?VB_Create@@YGHPAD@Z
名称修饰?这是什么标准?
I have a program that calls a set of function as follows:
int _stdcall VB_Create(char*);
int _stdcall VB_Open(unsigned int, unsigned int, unsigned int, unsigned int);
...
...
If there is a mismatch in the name decoration, the linker shows an error like this:
error LNK2019: unresolved external symbol "int __stdcall VB_Create(char *)" (?VB_Create@@YGHPAD@Z) .....
My understanding is that _stdcall
syntax is an '_' + 'name of the function' + '@' + 'number of arguments * 4'
.
So, why the linker is asking for ?VB_Create@@YGHPAD@Z
name decoration? what standard is this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是Visual C++ name mangling(我不知道有没有官方的MSDN 上的页面描述编码;我找不到)。
C++ 函数需要的不仅仅是将其名称编码到最终出现在二进制文件中的符号中:这些符号需要是唯一的,但 C++ 函数名称不需要是唯一的。除其他原因外,C++ 函数可以重载,不同命名空间中可以具有相同名称的函数,并且必须能够处理成员函数。
编译器使用一种紧凑的编码方案,就像这样,以便可以唯一地标识函数。
This is Visual C++ name mangling (I don't know that there is an official page on MSDN to describe the encoding; I could not find one).
C++ functions need more than just their name encoded into the symbol that ends up in the binary: those symbols need to be unique, but C++ function names need not be unique. Among other reasons, C++ functions can be overloaded, you can have functions with the same name in different namespaces, and you have to be able to handle member functions.
A compiler uses a compact encoding scheme, like this one, so that functions can be uniquely identiifed.
詹姆斯已经说过了:这是一个名字篡改的问题。 之后放置一个
之前和
在函数声明 。这将关闭 C++ 名称修改。 FWIW,
__stdcall
与此无关,尽管它是 VB、IIRC 所必需的。James already said it: it is a name mangling issue. Put a
before and a
after the function declarations. That will turn off C++ name mangling. FWIW,
__stdcall
has nothing to do with this, although it is required for VB, IIRC.