c++ - 智能感知 :expected a declaration in C++

标签 c++ visual-studio-2010

我正在尝试将 C 和 C++ 代码添加到一起,但最终出现上述错误,如 IntelliSense:expected a declaration

例如 abc.cpp

#include "abc.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "C_headerfiles.h"
...
...//Body of C code
#ifdef _cplusplus
}
#endif
...
...//Body of C plus plus code

#ifdef __cplusplus
extern "C"       //`IntelliSense:expected a declaration
{
#endif
...
...//Body of C code
#ifdef _cplusplus
}
#endif

最佳答案

我已经解决了这个问题:需要添加extern C only once not again and again

#include "abc.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "C_headerfiles.h"
...
...//Body of C code

...
...//Body of C plus plus code


...
...//Body of C code
#ifdef _cplusplus
}
#endif

关于c++ - 智能感知 :expected a declaration in C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14156532/

相关文章:

c++ - qsort 类对象列表

c++ - 这2张魔法卡能发挥的最大技能是多少?

c# - 显示用于调试 DLL 的控制台应用程序窗口

visual-studio-2010 - MFC 中的 libmodbus

c++ - 使用 GL_LINE_LOOP 绘制多个圆

c++ - HDF5 C++ 接口(interface) : writing dynamic 2D arrays

.net - Visual Studio 2010 远程调试 - 无法连接 : Access Denied

visual-studio-2010 - 如何跳回在 Visual Studio 2010 调试器中引发异常的代码行?

visual-studio-2010 - Visual Studio 2010 突然停止显示调试输出

python - boost python编译模块中缺少库