1

The first line of any file in my workspace is treated as if it's an include error. It has a red squiggly line and on hover says

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.

Also if the first line is a multiline comment then the second line (of the comment) has the error.

How do I fix this? Clearly comments can't have errors.

Edit: My include path is set, obviously I did that before asking this question. But even if I hadn't set it, this error still shouldn't be occurring on non-#include statements and even in comments!

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
otah007
  • 505
  • 1
  • 4
  • 17
  • Does it happen on every file in any language? Does it happen in empty files as well? – Álvaro González Aug 02 '19 at 11:42
  • Just googled it. I'd say it's [an issue with C++](https://github.com/Microsoft/vscode-cpptools/issues/1863) and you need to, well, set your includePath ;-) – Álvaro González Aug 02 '19 at 11:44
  • Possible duplicate of [#include errors detected in vscode](https://stackoverflow.com/questions/45583473/include-errors-detected-in-vscode) – Álvaro González Aug 02 '19 at 11:45
  • @ÁlvaroGonzález Include path is set, only happens in (most) C++ files. I'm not using MinGW or Windows so your linked GitHub issue isn't relevant. – otah007 Aug 02 '19 at 12:53
  • Thank you for the feedback. I've added the [tag:c++] tag so hopefully the question can be found by someone familiar with the feature. – Álvaro González Aug 02 '19 at 15:27

1 Answers1

0

I was able to get rid of this (temporarily) by clicking the light bulb when hovering over the squiggle error. Then, clicking 'Edit "includePath" setting'. Next, clicking the link in left side of the displayed page that says:

Switch to the c_cpp_properties.json file by clicking on the file link or using the command: C/C++: Edit configurations (JSON)

I then changed nothing in that file and saved it. It seems that by simply existing, the includePath issue is resolved and the squiggles disappeared.

I think this is likely a bug in VSCode where saving the json file "c_cpp_properties.json" populates "includePath"

Once you restart VSCode, the same thing with the squiggles will happen again. You can open the file "c_cpp_properties.json" and immediately click to save it, and the squiggles will again disappear.

kuberry
  • 21
  • 4