位置 帝国网站管理系统>职场>笔试面试>c++
extern

extern "C" • 被 extern 限定的函数或变量是 extern 类型的 • 被 extern "C" 修饰的变量和函数是按照

C 语言方式编译和链接 的 extern "C" 的作用是让 C++ 编译器将 extern "C" 声明的代码当作C 语言

代码处理,可以避免 C++ 因符号修饰导致代码不能和 C 语言库中的符号进行链接的问题。

使用

#ifdef __cplusplus

extern "C" {

#endif

void *memset(void *, int, size_t);

#ifdef __cplusplus

}

#endif