How to: Set Code Analysis Properties for C/C++ Projects

Note

This article applies to Visual Studio 2015. If you're looking for Visual Studio 2017 documentation, use the version selector at the top left. We recommend upgrading to Visual Studio 2017. Download it here.

The latest version of this topic can be found at How to: Set Code Analysis Properties for C/C++ Projects.

You can configure which rules the code analysis tool uses to analyze the code in each configuration of your project. In addition, you can direct code analysis to suppress warnings from code that was generated and added to your project by a third-party tool.

Code Analysis Property Page

The Code Analysis property page contains all code analysis configuration settings for a project. To open the code analysis property page for a project in Solution Explorer, right-click the project and then click Properties. Next, expand Configuration Properties and select the Code Analysis tab.

Project Configuration and Platform

The Configuration list and Platform list lets you apply different code analysis settings to different project configuration and platform combinations. For example, you can direct code analysis to apply one set of rules to your project for debug builds and a different set for release builds.

Enabling Code Analysis

You can decide whether to enable code analysis for your project by selecting Enable Code Analysis For C/C++ on Build. In combination with the Configuration list, you could, for example, decide to disable Code Analysis for debug builds and enable it for release builds.

If your project contains managed code, you can decide whether to enable or disable Code Analysis by selecting Enable Code Analysis on Build.

Code analysis is designed to help you improve the quality of your code and avoid common pitfalls. Therefore, consider carefully whether to disable code analysis. It is usually better to disable rule sets or individual rules that you do not want applied to your project.

Generated Code

Developers frequently use tools to help develop applications quickly. These tools can generate code that is added to the project. You might want to see the rule violations that code analysis discovers in generated code. However, you might not want to see them if you do not want to maintain the code.

The Suppress Results From Generated Code check box on the General properties page lets you select whether you want to see code analysis warnings from managed code that is generated by a third-party tool.

Rule Sets

If your project contains managed code, you can select the rules to apply in a code analysis by selecting a rule set from the Run this rule set list.

See Also

Analyzing Managed Code Quality
Code Analysis for C/C++ Warnings