我正在尝试在 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;
}
要开始分析,我使用“Analyze-> Run Code Analysis on ....”
和日志:
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 ==========
配置:
在“属性页面”上,我打开了:
- 启用代码分析 ob 构建(定义....
- 在构建时启用 C/C++ 的代码分析
- 抑制结果...
-and 规则集 ->AllRules
我的问题是我做错了什么,或者如何在 VS2010 中运行代码分析?
谢谢