Closed SandroWissmann closed 4 years ago
Make sure you have clang-tidy installed. The extension looks for clang-tidy on the PATH by default. You can use the clang-tidy.executable
setting if clang-tidy is not on your PATH.
If you can't get it to work, open up the output pane in VSCode, select "Clang-Tidy" in the dropdown menu, and paste the output here.
I installed clang-tidy and could run it in my ubuntu system from command line. So that means It should work already automatically?
And if not I have to modify the settings.json file and add the executable there?
edit:
I specified the path like this:
However nothing happens. Also in the output Window I cannot select tidy;
notskm notifications@github.com schrieb am Di., 2. Juni 2020, 20:40:
Make sure you have clang-tidy installed. The extension looks for clang-tidy on the PATH by default. You can use the clang-tidy.executable setting if clang-tidy is not on your PATH.
If you can't get it to work, open up the output pane in VSCode, select "Clang-Tidy" in the dropdown menu, and paste the output here.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/notskm/vscode-clang-tidy/issues/37#issuecomment-637735118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKD3YSE6MOHOZ5MWKZDH3HLRUVBRTANCNFSM4NQ2NKCA .
Do you have a .clang-tidy
file in the root of your project? If not, are you setting clang-tidy.checks
?
I cannot reproduce this issue.
how do i get this .clang-tidy file? Can I generate it?
Can you give an example what to write in the settings.json?
Here's clang-tidy's docs. https://clang.llvm.org/extra/clang-tidy/ This extension simply runs clang-tidy for you. You need to learn how to use clang-tidy first.
.clang-tidy
is the config file for clang-tidy. It's where you specify what checks you want enabled.
I checked the docs but I could not find out how to create the tidy file.
If I have the file and specified the path the extension should work automatically?
notskm notifications@github.com schrieb am Do., 4. Juni 2020, 20:47:
Here's clang-tidy's docs. https://clang.llvm.org/extra/clang-tidy/ This extension simply runs clang-tidy for you. You need to learn how to use clang-tidy first.
.clang-tidy is the config file for clang-tidy. It's where you specify what checks you want enabled.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/notskm/vscode-clang-tidy/issues/37#issuecomment-639048495, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKD3YSHHP4WRJ3ZRYGI2DW3RU7T47ANCNFSM4NQ2NKCA .
Here's an example .clang-tidy
file from one of my projects. See clang-tidy's docs if you need help with it. https://github.com/notskm/cpp-application-template/blob/master/.clang-tidy
You need to learn how to use clang-tidy from the command line if you want to use this extension.
This extension runs clang-tidy for you whenever you save. You can also run it manually from the command palette. You either need to set clang-tidy.checks
to the list of checks you want enabled, or you need to have a .clang-tidy
file with the list of checks you want enabled in the root of your project. See README.md.
Ok. I added the .clang-tidy file to the project.
And I added the path of clang-tidy to settings.json like this:
"clang-tidy.executable": "/usr/bin/clang-tidy",
But I still don't see anything happen when I save a file. Am I still missing something?
I have no idea why it's not working for you. It should be. The output window still doesn't have a clang-tidy section?
It looks like it is working now in the Problesm Clang Diagnostics error show up.
However one Issue I have. It looks like clang-tidy does not find additionally specified headers and marks them as errors.
In my case I get a complain that SDL.h is not found like this:
'SDL.h' file not found [clang-diagnostic-error]
So do I have to additonally include the path to SDL to clang-tidy?
I already specified it for intellisense in c_cpp_configurations.json like this:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/SDL2/**",
"/mnt/Programmierung/Cpp/Udacity/Project/Bricks/thirdparty/googletest/googletest/include/**"
],
"browse": {
"limitSymbolsToIncludedHeaders": false,
"path": [
"${workspaceFolder}/**",
"/usr/include/SDL2/**",
"/mnt/Programmierung/Cpp/Udacity/Project/Bricks/thirdparty/googletest/googletest/include/**"
]
},
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
That sounds like you don't have a compile_commands.json
file in your project. If you're using CMake, it can generate one for you by specifying -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
on the command line. I think the CMake Tools extension also has a setting for that. Other build tools may also provide some means to generate compile_commands.json
, but I'm not sure.
Many tools rely on compile_commands.json
being present. Clang-Tidy should find it automatically if it's in the root of your project. Otherwise, you can use this extension's clang-tidy.buildPath
setting to tell clang-tidy where to look.
Thanks a lot now it is working well.
I generated the compile_commands.json
with CMake from command line like you suggested.
Now tidy works well.
Thank you very much for your patience.
No problem. I'm glad it's working.
This is easy to fix but gives a bad first impression when not discovered. Could you add this to a setup page for some generic project setups like cmake based projects?
So I installed the Extension under Ubuntu but nothing is happening.
I would appreciate instructions on how to set it up.