admin管理员组

文章数量:1122846

I use Ninja 1.10 to build the project and MSVC 14.42.34433 to compile the project.

I didn't use the Visual Studio toolchain; instead, I copied the MSVC, WDK, and SDK folders to a separate directory and configured the relevant paths in CMake myself.

In order to analyze the code, I added the following compiler options:

    target_compile_options(dxu PRIVATE "/FIrgxdefs.h")
    target_compile_options(dxu PRIVATE "/analyze")
    target_compile_options(dxu PRIVATE "/analyze:external-")
    target_compile_options(dxu PRIVATE /analyze:projectdirectory ${CMAKE_SOURCE_DIR_SLASHIFIED})
    target_compile_options(dxu PRIVATE /analyze:ruleset ;RuleSet1.ruleset;)
    target_compile_options(dxu PRIVATE "/analyze:pluginEspXEngine.dll")

Among them, RuleSet1.ruleset is a rule file that I wrote myself, and it is placed in the root directory of the project. Its contents are as follows:

<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="New Rule Set" Description=" " ToolsVersion="17.0">
  <Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
    <Rule Id="C26495" Action="Error" />
  </Rules>
</RuleSet>

Code analysis indeed only detects C26495, but it is flagged as a warning rather than an error.

I tried changing the Action to Error, Warning, Info, and Hidden, and found that as long as it’s not set to Hidden, it always shows as a Warning.

本文标签: cMSVC Code Analyze can only show warnings and can39t show errorStack Overflow