将调用约定从 cdecl 更改为 stdcall
在 VS2005 中,我使用 _cdecl 调用约定,并且项目构建时没有任何链接器错误。在将项目移植到 VS2008 时将调用约定更改为 _stdcall 后,出现以下错误:
错误 LNK2001:无法解析的外部符号 __imp__GCBOpen@8。
配置设置>C\C++>常规>公共语言运行时支持设置为无公共语言运行时支持
我需要有关解决问题所需的任何项目设置或代码更改的帮助。 任何帮助表示赞赏。
In VS2005, I was using _cdecl calling convention and the project builds without any linker errors. After I change the calling convention to _stdcall while porting the project to VS2008, I get the following error:
error LNK2001: unresolved external symbol __imp__GCBOpen@8.
Configuration Settings>C\C++>Genral>Common Language Runtime support is set to No Common Language Runtime support
I need help regarding any project settings or code changes that need to be done in order to resolve the issue.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
GCBOpen()
已编译为__cdecl
,但其声明并未明确说明这一点。 (这就是为什么当您的默认值是 __cdecl 时它链接正常,但是当您更改它时它会中断。)一般来说,在外部库中声明函数时指定调用约定以避免诸如你遇到过的一个。在某个地方你必须有类似的东西:
这会更好:
It looks like
GCBOpen()
is compiled__cdecl
but its declaration does not explicitly state that. (That's why it linked OK when your default was__cdecl
but breaks when you change it.) In general it is good practice for declarations of functions in external libraries to specify the calling convention to avoid problems such as the one you have enountered.Somewhere you must have something like:
which would be better off as: