在 pro*C 文件中调用 C 函数

发布于 2024-09-04 07:14:06 字数 238 浏览 2 评论 0 原文

我的 pro*C 程序中有这些行。函数 initAverage(int i) 是用 C 语言定义的,我试图在 .pcc (Pro C++) 文件中调用此函数。

我收到错误

Error: initAverage(int i);was declared before with a different language

extern "C"
{
int initAverage(int i);
}

I have these line in my pro*C program. The function initAverage(int i) is defined in a C language and I am trying to call this function in a .pcc (Pro C++) file.

I am getting an error

Error: initAverage(int i);was declared before with a different language

extern "C"
{
int initAverage(int i);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

白况 2024-09-11 07:14:06

您可能之前有一个 include 已经声明了 initAverage 而没有 extern "C"。查看 initAverage 的所有声明并修复缺少的 extern 声明,这样就可以了。

附:
添加 调用约定 明确是一个好主意。我也会补充这一点(虽然实际上不是问题的一部分)

You probably have an include before that already declares initAverage without extern "C". Look at all declarations of initAverage and fix the missing extern declaration then it should be fine.

PS:
Adding the calling convention explicitly is a good idea in general. I would add that too (while not being actually part of the question)

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