【发布时间】:2022-10-14 22:35:18
【问题描述】:
在我的头文件foo.h 中,我有:
#ifdef __cplusplus
extern "C" {
#endif
int foo(int x);
#ifdef __cplusplus
}
#endif
现在,在foo.cpp 中,我是否也应该使用extern "C",并定义:
#include "foo.h"
extern "C" {
int foo(int x);
};
?或者声明是否足以确保 C 链接(没有名称修改)?
【问题讨论】:
标签: c++ header forward-declaration function-declaration extern-c