microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Add the ability to disable certain linter errors #2345

Open andylizf opened 6 years ago

andylizf commented 6 years ago

Type: LanguageService

Many people use g++ (MinGW on Windows), and I am also like this. g++ extends some C99 features in C++, such as array lengths that can be defined with variables which is considered a error by VS Code.

treats it as an error

auto a = new int[l]; in standard C++. auto a[l]; in g++ and C99.

I know that defining with a const is a standard C++ convention, and it is also common sense. But in some cases (such as algorithms), it is convenient to use variable definitions.

I think it's a good idea to let me remove some of the error.(because VS Code is a. editor that doesn't know how the compiler handles certain "errors") Add a point to disable the static error prompt in source, in file or in global setting. Just like in user settings, we can list all static error types.

We can also make g++ specification. This specification remove some features which are not supported in VS Code. The default is the original specification. But when I use g++ in tasks.json, it can automatically enable. It seems that there is a similar error specification function in VS.

andylizf commented 6 years ago

Not similar to #2299. Assigning array lengths with variables causes an error in standard C++, and doesn't cause in g++ using the C99 extension.

sean-mcmanus commented 6 years ago

This error should go away when you set your compilerPath to something like "C:\MinGW\bin\g++.exe" or your intelliSenseMode to clang-x64 (in c_cpp_properties.json).

We've had previous requests for some error ignoring feature: https://github.com/Microsoft/vscode-cpptools/issues/1231 .

andylizf commented 6 years ago

Great! Specializations for special compilers are necessary.

sean-mcmanus commented 6 years ago

https://github.com/Microsoft/vscode-cpptools/issues/791 is somewhat related (i.e. we could attach an error code to missing include messages to allow users to filter them out).

aaronfranke commented 5 years ago

Same feature request here, I was about to open a duplicate issue, then I found this.

Originally posted here: https://github.com/Microsoft/vscode/issues/72669

Describe the bug

What I would like to do is ignore a specific token/string from code validation / error checking.

1

Everything else shows up properly as not being an error, but this "TTR" text is underlined in red. I already know that this code runs properly, so I would just like to exclude VS Code from underlining this piece of text in red, so that it is ignored, and I do not have to see these errors when scrolling through the code.

I'm not asking for help for resolving the underlying problem of VS Code not understanding this token. I just want to disable this error from showing up. Perhaps some configuration file where I can put text or tokens to ignore, probably each one on its own line to allow multiple ignores.

sean-mcmanus commented 4 years ago

FYI, you can use

#ifdef __INTELLISENSE__
    #pragma diag_suppress 28
#endif

to suppress the "expression must have a constant value" error. We don't expose the error numbers yet (for other errors), but we may add those later on.

sean-mcmanus commented 4 years ago

With https://github.com/microsoft/vscode-cpptools/releases/tag/0.30.0-insiders4 , we show the IntelliSense error codes, so

#ifdef __INTELLISENSE__
    #pragma diag_suppress 28
#endif

could be used as a workaround for suppressing IntelliSense errors (replace 28 with the error code).

github-actions[bot] commented 4 years ago

This feature request has received enough votes to be added to our backlog.