0

I've just started learning how to program. I set up VSCode on my Mac and the C/C++ extension. I wrote the helloworld program from Stroustrup's Programming and Principles book. I put the std_lib_facilities.h file in the same folder as my helloworld.cpp file. Still I get the error message: #include errors detected. Please update your includePath. Squiggles are disabled for this translation unit.

Why am I still getting the error? The book says all I need is to have the std_lib_facilities.h.txt file in the same directory as my .cpp program. They're in the same folder, so why am I getting this error?

My code:

#include "std_lib_facilites.h"

int main()
{
    cout << "Hello World \n";
    return 0;
}
  • Does this answer your question? [Is c++ std\_lib\_facilities.h still used?](https://stackoverflow.com/questions/45877104/is-c-std-lib-facilities-h-still-used) – Gino Mempin Apr 11 '20 at 12:35
  • thanks, all I did now for it to get the text file was type: #include "full directory path", i.e: #include "Users/Venkat/project/helloworld/std_lib_facilites.h" – STRICKLAND_7 Apr 11 '20 at 12:45
  • Thanks Gino, from one of the answers/comments from the question you linked, turns out I had to download a new version of the std_lib_facilities file and turns out I have to write the .txt after the .h too! – STRICKLAND_7 Apr 11 '20 at 12:57

1 Answers1

0

First of all, you have a typo in the filename.

#include "std_lib_facilites.h"

It should be std_lib_facilities.h (source 1, source 2).
And make sure to save it as .h.

Second, you can configure a .vscode/c_cpp_properties.json file to specify the path to the header files. See the VS Code docs for the JSON schema reference.

  1. Open the Command Palette
  2. Select "C/C++: Edit Configurations (JSON)"
  3. Set the includePath
 "configurations": [
     {
         "name": "Mac",
         "includePath": [
             "${workspaceFolder}/**",
             "/path/to/headers"
         ],
         ...
     }
 ],

By default it already has "${workspaceFolder}/**" which should search for header files in your workspace (and its sub-folders). But you can also specify paths to other folders.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135