Visual Studio build vs intellisense warnings. What is the difference, and why does pragma warning(disable) not remove intellisense warning?

Viewed 1142

Been trying to clean up warnings on a project. I've been disabling warnings for certain 3rd party include files, and I'm at the point that if I set the filter in the "Error List" to "Build Only", I'm not getting any warnings, but I still see close to 200 warnings if I set the filter to "IntelliSense Only" or "Build + Intellisense".

I'm don't quite get what the difference is, or how to disable certain warnings for both build and intellisense. For example, I'm getting warning C6263: Using _alloca in a loop: this can quickly overflow the stack." in any place that we use the T2W or A2W macro, even in a file that I'm pretty sure I've disabled the warning using this in our stdafx.h file:

#pragma warning(push)
#pragma warning(disable: 6263)
#include <atldlgs.h>
#pragma warning(pop)

I'm not sure why the warning is an IntelliSense warning and not a Build warning, (i.e. I don't see anything in the build output that reflects the warning I see in the Error List window), and I'm not sure how you can disable IntelliSense warnings via pragmas.

Note that I'm not trying to disable code analysis, or IntelliSense. I'm trying to disable SOME of the warnings that are showing up in the "Error List" window when building, which appear to come from IntelliSense.

1 Answers

If you want to disable Intellisense, you could set True in Tools->Options->Text Editor->C/C++->Advanced->Disable IntelliSense.

If you want to disable specific errors, you could refer to Microsoft Docs about warning pragma.

Syntax

#pragma warning(
    warning-specifier : warning-number-list
    [; warning-specifier : warning-number-list ... ] )
#pragma warning( push [ , n ] )
#pragma warning( pop )

Also, you could refer to this link about how To disable all code analysis warnings for included third-party files.

Add the following code to your header file.

#include <codeanalysis\warnings.h>
#pragma warning( push )
#pragma warning ( disable : ALL_CODE_ANALYSIS_WARNINGS )
#include <third-party include files here>
#pragma warning( pop )
Related