Visual Studio Code: C ++ Includes Path

I am currently using https://marketplace.visualstudio.com/items?itemName=mitaki28.vscode-clang , which is great for a small tool for accessing member functions.

I have one problem with the project that I am importing. While the above clang function works, I am having a special problem using include directories. My project structure is as follows:

|- src/ |- main.cpp |- include/ |- MyHelper.h |- CMakeLists.txt 

Is there a way to configure my included directories in Visual Studio code, so in main.cpp I can just do: #include "MyHelper.h" instead of #include "include/MyHelper.h"?

In the editor, he highlights my include statement, saying that he cannot find the file. While the editor does not really matter (my project is compiling), the next problem is that the vscode-clang plugin does not work because it does not see the file.

Perhaps even if it uses the configuration from my CMakeLists.txt in the editor for which you need to enable it?

Thanks!

+5
source share
1 answer

Well, that was stupid, but in case someone uses Visual Studio Code and doesn't have a trivial project. These instructions assume that you are using the clang compiler:

  • Open the project directory
  • Open .vscode/settings.json
  • Customize the line below inside the JSON object:

     // Compiler options for C++ (eg ['-std=c++11']) "clang.cxxflags": [ "-I/path/to/my/include/directory" // header files ], 
+5
source

Source: https://habr.com/ru/post/1245447/


All Articles