Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to disable certain linter errors #2345

Open
andylizf opened this issue Aug 1, 2018 · 8 comments
Open

Add the ability to disable certain linter errors #2345

andylizf opened this issue Aug 1, 2018 · 8 comments

Comments

@andylizf
Copy link

andylizf commented Aug 1, 2018

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
Copy link
Author

andylizf commented Aug 1, 2018

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
Copy link
Contributor

sean-mcmanus commented Aug 1, 2018

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: #1231 .

@andylizf
Copy link
Author

andylizf commented Aug 2, 2018

Great! Specializations for special compilers are necessary.

@sean-mcmanus
Copy link
Contributor

#791 is somewhat related (i.e. we could attach an error code to missing include messages to allow users to filter them out).

@aaronfranke
Copy link

aaronfranke commented Apr 23, 2019

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

Originally posted here: microsoft/vscode#72669

Describe the bug

  • OS and Version: Xubuntu 18.04.2 64-bit
  • VS Code Version: 1.33.1
  • C/C++ Extension Version: 0.22.1

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
Copy link
Contributor

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.

@bobbrow bobbrow changed the title Make some of the error hints can be disabled for special handling by some compilers. Add the ability to disable certain linter errors Aug 28, 2020
@bobbrow bobbrow modified the milestones: Postponed, Triage Aug 28, 2020
@sean-mcmanus
Copy link
Contributor

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants