Visual Studio 2015 offers the option to show Intellisense errors in the same window that also displays regular build errors. I like it because I don't even need to build in order to see if the syntax of my code is correct.
However, the window also shows one false positive error which seems to be related to an Intellisense bug. Is there any way to suppress intellisense errors for specific code regions or entire files?
Old question, I know, but I just had a similar complaint with Visual Studio 2019 / IntelliSense and found a solution.
My particular example is C++ and relates to the use of Variable-Length Arrays. Clang supports/compiles them and I can suppress build warnings by adding a -Wno-vla
option (Properties -> C/C++ -> Command Line -> Additional Options
).
However, IntelliSense ignores the "-Wno-vla" seeing VLA as an error, not warning. So come the red squiggles in the code and in its Error List: E0028 expression must have a constant value
(this error number 28 is significant below)
The key is to remember that IntelliSense uses a different compiler front-end, so may have a different idea about what's "correct" than your selected build compiler and options. The front-end is licensed from EDG and fortunately, they document some of its operation, including command-line options, pragmas, etc. here: C++ Front End PDF
I couldn't figure out how to direct their command-line options exclusively to their front-end, which appears to pull its options from the project, the same ones the build compiler uses... and it chokes on those options, especially ones expecting a parameter after a space (for instance --diag_suppress 28
never worked).
Yet what I could get to work were the front-end-specific pragmas! So that required a small amount of non-portable code. Specifically, I put the following into one of my top-level ("included by everyone") header files, and it worked great:
#ifdef __INTELLISENSE__
#pragma diag_suppress 28
#endif
Without the __INTELLISENSE__
clause, you could also do: #pragma clang diagnostic ignored "-Wunknown-pragmas"
Did you find an answer? You can do it by writing the following in your code on the line prior to where the error is raised
#pragma warning disable XXXX
where XXXX is the error code without the "CS"
Or you can try these steps to suppress specific warnings for Visual C# or F#
taken from here https://msdn.microsoft.com/en-us/library/jj715718.aspx
Note that warnings are mentioned rather than errors, but for me they are listed as errors if I choose to show Suppressed Errors in the Error List window. You might need to enable this column in the Error List window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With