我试图在VS2010中使用代码分析,但它无法正常工作。
我的示例应用:
#include "stdafx.h"
#include <malloc.h>
int getj() {
return 10;
}
int a(int *n) {
int b = *n;
int c = 1/b;
return c;
}
int _tmain(int argc, _TCHAR* argv[]) {
int *a;
a = (int *)malloc(10*sizeof(int));
if( a ) {
free( a );
a[0] = 12;
a[getj()] = 12;
}
return 0;
}
要开始分析,我使用&#34; Analyze-&gt;在....&#34;
上运行代码分析和日志:
1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
1>Build started 2013-07-01 17:45:40.
1>_PrepareForClean:
1> Deleting file "Debug\test1.lastbuildstate".
1>InitializeBuildStatus:
1> Creating "Debug\test1.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1> stdafx.cpp
1> test1.cpp
1>Manifest:
1> Deleting file "Debug\test1.exe.embed.manifest".
1>LinkEmbedManifest:
1> test1.vcxproj -> D:\test1\Debug\test1.exe
1>RunCodeAnalysis:
1> Running Code Analysis...
1> **Code Analysis Complete -- 0 error(s), 0 warning(s)**
1>FinalizeBuildStatus:
1> Deleting file "Debug\test1.unsuccessfulbuild".
1> Touching "Debug\test1.lastbuildstate".
1>![enter image description here][1]
1>Build succeeded.
1>
1>Time Elapsed 00:00:03.40
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
配置:
在&#34;属性页面&#34;上,我已打开:
-Enabled Code Analysis ob Build(定义....
- 在构建
上启用C / C ++的代码分析- 来自...的结果
- 和Ruls Set - &gt; AllRules
我的问题是我做错了什么,或者如何在VS2010中运行代码分析?
谢谢