将调用约定从 cdecl 更改为 stdcall

发布于 2024-09-13 04:59:36 字数 241 浏览 4 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心奴独伤 2024-09-20 04:59:36

看起来 GCBOpen() 已编译为 __cdecl,但其声明并未明确说明这一点。 (这就是为什么当您的默认值是 __cdecl 时它链接正常,但是当您更改它时它会中断。)一般来说,在外部库中声明函数时指定调用约定以避免诸如你遇到过的一个。

在某个地方你必须有类似的东西:

__declspec(dllimport)
extern int GCBOpen(int, int);

这会更好:

#define CALLCONV __cdecl
__declspec(dllimport)
extern int CALLCONV GCBOpen(int, int);

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:

__declspec(dllimport)
extern int GCBOpen(int, int);

which would be better off as:

#define CALLCONV __cdecl
__declspec(dllimport)
extern int CALLCONV GCBOpen(int, int);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文