我有一些从 C++ 调用的 C 代码。
标头类似于以下内容:
#ifndef CLibH
#define CLibH
#ifdef __cplusplus
extern "C" {
#endif
//C API
void foo(void);
// ...
#ifdef __cplusplus
}
#endif
#endif
由于我已经在使用extern C
,
添加nothrow
编译器属性有什么好处吗?
#ifndef CLibH
#define CLibH
#ifdef __cplusplus
extern "C" {
#endif
//C API
void foo(void) __attribute__((nothrow));
// ...
#ifdef __cplusplus
}
#endif
#endif
是否extern C
使这变得多余?
在这种情况下应用它还有优势吗?