c++ – Disable single warning from IntelliSense linter


I’m trying to disable single IntelliSense linter warning/message in Visual Studio 2022 (Community).
lnt-make-member-function-const The member function can be made const. D:\tests\Linter\Window.cpp 6

I didn’t find any info on microsoft website how to configure that in code https://learn.microsoft.com/en-us/cpp/ide/cpp-linter-overview?view=msvc-170

AI suggested to use NOLINT/NOLINTBEGIN/NOLINTNEXTLINE but that doesn’t work and it’s clang-tidy syntax.

MRE:

//Window.h
#pragma once

class Window
{
public:
    void Show();

private:
    int x;
};

//=============================
// Window.cpp
#include "Window.h"
#include <Windows.h>

// NOLINTBEGIN
// NOLINTNEXTLINE
void Window::Show() // NOLINT
{
    ShowWindow(nullptr, x); // just an example :)
}
// NOLINTEND

//=============================
//Source.cpp
#include "Window.h"

int main()
{
    Window w{};
    w.Show();
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *