0

I am trying add C and C++ code together, but end up with getting above error as IntelliSense:expected a declaration.

e.g 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
Rasmi Ranjan Nayak
  • 11,510
  • 29
  • 82
  • 122

1 Answers1

1

I have solved this problem: Need to add the 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
Rasmi Ranjan Nayak
  • 11,510
  • 29
  • 82
  • 122