0

I have a bunch of these warnings showing up in my C++ code. I don't want to see them.

So I added the key to the list of disabled warnings. But there is no change. Visual Studio Code keeps showing me these things in the "Problems" list. How do I disable them?

Rob N
  • 15,024
  • 17
  • 92
  • 165
  • what if you reload the window? – starball Jul 08 '23 at 19:06
  • The problem persists. – Rob N Jul 08 '23 at 19:36
  • It would help to see the `clang-tidy` command VSCode is running. In Settings, change "C_Cpp: Logging Level" to "Debug", then re-run code analysis and look in the Output window (View -> Output), in the "C/C++" tab. – Scott McPeak Jul 08 '23 at 22:04
  • I get nothing in the panel. When I try to run an Analyze command, I get a popup in lower right that says: "IntelliSense-related commands cannot be executed when `C_Cpp.intelliSenseEngine` is set to `disabled`." I don't remember setting that. But I have installed the clangd extension, so I maybe it did? – Rob N Jul 10 '23 at 18:33

1 Answers1

1

Problem diagnosis

The issue is you have installed the clangd extension, which runs the clangd program in the background. clangd embeds the clang-tidy functionality (doc link), and it runs in the background automatically, contributing problem reports to the VSCode "Problems" window.

This is different from how the C/C++ extension works, invoking clang-tidy in response to the palette command "C/C++: Run Code Analysis on Active File". The configuration setting "C_Cpp > Code Analysis > Clang Tidy > Checks: Disabled" only affects clang-tidy when invoked by the C/C++ extension, not the clangd extension.

Solution

To influence the clang-tidy that runs as part of clangd, you have to create a .clang-tidy file in your project directory.

For example, this .clang-tidy will disable misc-unused-using-decls:

---
Checks: '-misc-unused-using-decls'

Having created a .clang-tidy file like that, the next time you modify your source file (even without saving), the findings produced by that checker will disappear from the Problems window.

A forgotten prompt?

Since the clangd extension and the C/C++ extension both provide language services, the former prompts to disable the latter upon installation with a dialog that looks like this:

Prompt from clangd extension to disable intellisense

Presumably, this prompt appeared when you added the clangd extension, and you clicked to disable Intellisense at that time, but forgot about it (understandably). It's also far from obvious that doing so changes how clang-tidy runs, and thereby obviates the related settings in the "C_Cpp > Code Analysis" section, but it turns out it does.

Scott McPeak
  • 8,803
  • 2
  • 40
  • 79