I am mostly programming in C, yet some of my code is in C++. The code compiles fine using gcc/g++ under Linux, yet VisualStudio Code's IntelliSense is reporting include errors with the following setup:
// file1.c
#include "includefile1.h"
IntelliSense reports
#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.
cannot open source file "atomic" (dependency of "includefile1.h"). Please run the 'Select IntelliSense Configuration...' command to locate your system headers.
The includefile1.h is written in C++ and would include things like
// includefile1.h
#include <atomic>
Compiling works fine, yet the IntelliSense errors are bothering me when working with VSCode.
- Is there a fix to that?
- Is there something I can add to the
c_cpp_properties.jsonto point IntelliSense to the correct paths? - Do I have to adjust something else, given that I am mixing C and C++?
#includedirective, it replaces the directive with the contents of the included file, effectively pasting the the included file into the including file. Once all of the preprocessing is done, the combined file is compiled. So what you have here is a C file containing C++ code being processed by a C compiler.In some compilers the line between C and C++ is very blurry. GCC for example uses the same compiler back end for both C and C++, so the earliest you're likely to find problems is when the program links.#include "blabla, without the closing double quote. Can the problem be this?