我有一个标题 my.h,其中有一个名为 my_func 的函数的以下声明。
#pragma once
void my_func (int *this);
Run Code Online (Sandbox Code Playgroud)
这个函数是在my.c中实现的
void my_func (int *this)
{
printf("%d", *this);
}
Run Code Online (Sandbox Code Playgroud)
在 foo.cpp 我想使用 my_func
extern "C"
{
#include <foo.h>
}
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误错误:expected ')' void my_func (int *this); 实际上在我的项目中,它在 .C/.h 文件中的很多地方使用/操作。这在许多头文件/.c 文件中用作变量。为了简单起见,我只是采用了上面的示例来描述我面临的编译错误。