I'm a noob please don't hate me.
I'm using cmake and vscode for a cpp project.
- Compiling is fine but clang says it can't find my headers and underline them although it also show me the path so it knows where they are... file not found
- including the relative path fixes the problem but its less clean :
"../include/myHeader.hpp" vs "myHeader.hpp"
I have export compile command on
in my presets :
{
"version": 2,
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"binaryDir": "${sourceDir}/build",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_CXX_FLAGS_INIT": "-std=c++17 -g -Wall -Wextra -Wpedantic -Werror -Weffc++ -Wshadow -O0"
}
},
{
"name": "release",
"displayName": "Release",
"binaryDir": "${sourceDir}/build",
"generator": "Unix Makefiles",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_CXX_FLAGS_INIT": "-std=c++17 -march=native -flto -O3 -DNDEBUG"
}
}
]
}
and in my vscode settings:
"C_Cpp.intelliSenseEngine": "disabled",
"C_Cpp.configurationWarnings": "disabled",
"clangd.path": "/home/pa/.config/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/16.0.2/clangd_16.0.2/bin/clangd",
"clangd.arguments": [
"-log=verbose",
"-pretty",
"--background-index",
"--compile-commands-dir=${workspaceFolder}/build/",
"--completion-style=detailed"
// "--query-driver=/bin/arm-buildroot-linux-gnueabihf-g++", // for cross-compile usage
],
"[cpp]": {
"editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd"
If someone knows how to fix this it would be great...
Thanks !
c_cpp_properties.json
: https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference