if you're an exceptionally attractive individual like me, the only things preventing you from retiring clion and adopting vscode (for everything) are clang-tidy and cppcheck. we can get clang-tidy by upvoting this feature request for adding clang-tidy support to the cpp extension for vscode: https://github.com/microsoft/vscode-cpptools/issues/2908
clang-tidy good. more clang-tidy.
Hello,
I am working through various complaints from clang-tidy, clang and cppcheck. I have a couple questions with a Vulkan CMake project . I am having a bit of time setting everything properly. Note everything builds with Cmake.
-
with Clang-tidy I know of the .clang-tidy file in project root directory. But I am not understanding how to let clang-tidy know of the Include paths. It is finding the Vulkan header files though I at this point I am not certain how. However it is not finding GLFW/glfw3.h header files. I am at a loss of how to proceed. CoPilot mentions compile_commands.json but creating one has not solved my problem.
-
flylint has a number of settings including for includePaths. The questions will clang and cppcheck inherit the includePaths setting from the flylint.includePaths variable or do I have to set those all separately . Of course this course if inheritance should apply to a number of other flylint variables.
Thanks,
Frank
If you are using CMake, VSCode has CMake plugins to help you build the project. So you do not need to modify the settings.json. Just use:
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
Or if there are no other modules used the header files in that folder you could use something like:
target_include_directories(MyHelper "${CMAKE_CURRENT_SOURCE_DIR}/include")
If you only need the project be built successfully. That is the whole story.
In the case of that, you got some little green zigzag lines under the #include statements hurting your eyes. You need to generate c_cpp_properties.json. It has nothing to do with helping the compiler to build the code but for helping VSCode intellisense to realize the existence of libraries and header files. And again, you are able to leverage the CMake by adding CMake options in the CMakeLists.txt:
add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
The CMake will generate a file compile_commands.json under your build directory. The VSCode is able to parse the Json file and find the include path based on the content in that file. So what you need to do is just letting VSCode know where is the Json file. You can do that by adding follwing line in the c_cpp_properties.json:
"configurations": [
{
"name": "Mac",
"compileCommands": "${workspaceFolder}/build/compile_commands.json",
...
}],
Rebuild the project will let the VSCode intellisense find all necessary paths.
[Environment]
Ubuntu: 16.04.3
VSCode: 1.23.1
VSCode plugins: C/C++ 0.17.0, CMAKE 0.0.17, CMakeTools 0.11.1
Okay, this was foolish, but in the event someone uses Visual Studio Code and does not have a trivial project. These instructions are assuming you're using clang compiler:
- Open your project directory
- Open
.vscode/settings.json Configure the line below inside of the JSON object:
// Compiler options for C++ (e.g. ['-std=c++11']) "clang.cxxflags": [ "-I/path/to/my/include/directory" // header files ],
I use Codium with the clangd and clang-tidy extensions; However, I can't find any info on how to tell these programs to find header files in the "src" and "lib" directories; which I include, for example like #include <foo/bar.h> (compiled with the options -I lib -I src)
I don't want to have to laboriously insert header files using ../../../foo/bar.h ... and I certainly don't want to miss out on the support provided by the Codium extensions mentioned.
Hello,
I am working through various complaints from clang-tidy, clang and cppcheck. I have a couple questions with a Vulkan CMake project . I am having a bit of time setting everything properly. Note everything builds with Cmake.
-
with Clang-tidy I know of the .clang-tidy file in project root directory. But I am not understanding how to let clang-tidy know of the Include paths. It is finding the Vulkan header files though I at this point I am not certain how. However it is not finding GLFW/glfw3.h header files. I am at a loss of how to proceed. CoPilot mentions compile_commands.json but creating one has not solved my problem.
-
flylint has a number of settings including for includePaths. The questions will clang and cppcheck inherit the includePaths setting from the flylint.includePaths variable or do I have to set those all separately . Of course this course if inheritance should apply to a number of other flylint variables.
Thanks,
Frank