visual studio 2010 -智能感知:期望在c++中有一个声明



我正在尝试将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而不是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

相关内容

最新更新