There are various posts about this - but I can't seem to find a definitive answer. Some people are saying it works and others not, and yet others saying its tools / IDEs that are the issue.
So I made as small an example as I could. Here are the two files I have:
compile_commands.json
[
{
"arguments": [ "gcc", "test.cpp" ],
"directory": "/home/user/development/sandbox/comp_commands",
"file": "test.cpp"
}
]
test.cpp
bool is_it()
{
// no return value - give clang warning
}
Now if I run the command clang-tidy test.cpp
in the same directory as the files I get:
[user] comp_commands$ clang-tidy test.cpp
1 warning generated.
test.cpp:4:1: warning: non-void function does not return a value [clang-diagnostic-return-type]
}
... as expected. However if I change the line in the compile_commands.json directory to:
"directory": ".",
Then I get the output:
[user] comp_commands$ clang-tidy test.cpp
Skipping /home/user/development/sandbox/comp_commands/test.cpp. Compile command not found.
here "MaskRay"s answer suggests this is fine/works. Since I am using no IDE, just clang-tidy directly- it can't be the IDE...
Is it possible to use relative paths in the compile_commands.json file? - I am generating this file via a script and can use either, but I specifically want it to be relative paths.