VS2011代码分析

5
我最近安装了VS2011 beta版本,以体验微软在最新版本编译器中实现的新C++11特性。
但是,当我回到使用VS2010时,遇到了一个意外的问题。我在VS2010中打开了一个Windows SDK 7.1示例项目。
现在,在VS2010中进行构建时,我会得到以下输出,表示正在执行代码分析工具(似乎是在编译之后,链接之前)。
1>------ Rebuild All started: Project: MFCaptureToFile, Configuration: Debug Win32 ------
1>  winmain.cpp
1>  capture.cpp
1>  Running Code Analysis for C/C++...
1>capture.cpp(112): error C2220: warning treated as error - no 'object' file generated
1>c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\mediafoundation\mfcapturetofile\capture.cpp(105): warning C6309: Argument '3' is null: this does not adhere to function specification of 'IMFAttributes::GetAllocatedString'
1>c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\mediafoundation\mfcapturetofile\capture.cpp(105): warning C6387: 'argument 3' might be '0': this does not adhere to the specification for the function 'IMFAttributes::GetAllocatedString': Lines: 98, 103, 105
1>c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\mediafoundation\mfcapturetofile\capture.cpp(353): warning C6309: Argument '3' is null: this does not adhere to function specification of 'IMFAttributes::GetAllocatedString'
1>c:\program files\microsoft sdks\windows\v7.1\samples\multimedia\mediafoundation\mfcapturetofile\capture.cpp(353): warning C6387: 'argument 3' might be '0': this does not adhere to the specification for the function 'IMFAttributes::GetAllocatedString': Lines: 336, 338, 340, 343, 351, 353
1>C:\Program Files\Microsoft SDKs\Windows\v7.1\Include\ks.h(53): error C2220: warning treated as error - no 'object' file generated
1>c:\program files\microsoft sdks\windows\v7.1\include\ks.h(53): warning C6244: Local declaration of 'GUID_NULL' hides previous declaration at line '28' of 'c:\program files\microsoft sdks\windows\v7.1\include\cguid.h'
1>  Generating Code...
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

我试图确定项目中的哪个更改导致了代码分析工具的执行,但我在项目属性中找不到任何信息。我尝试在VS2011中重新加载项目,但我找不到可以关闭代码分析的选项(如MSDN所建议)。

该项目完全是本机C++,我从未使用过带有CLR的C++。

此外,我尝试打开其他项目(我的项目),现在它们也会调用此代码分析阶段。这在许多情况下会导致由于Microsoft代码的问题而无法构建! 在VS2011 beta中似乎可以成功构建。

有人能够提供有关如何关闭此代码分析工具的见解吗? 我希望保留安装的VS2011 beta版本,请勿建议卸载它,除非这是唯一的选择!

1个回答

12

我认为只有VS2010 Ultimate支持代码分析。我没有VS2012,但我认为您应该手动编辑vcxproj文件。

寻找项目文件中是否存在以下一个或两个参数:   <RunCodeAnalysis>true</RunCodeAnalysis><EnablePREfast>true</EnablePREfast>

将这两个值都改为false,然后就可以工作了。

请注意,这些名称是由VS2010使用的,我不确定它们在VS2012中是否更改了。


9
哇。我知道肯定有人遇到过这个问题。像这样的回答是对该网站运作方式的赞誉。+1 - sehe
静态代码分析也包含在专业版和高级版中:https://www.microsoft.com/visualstudio/11/de-de/products/compareVS2012和VS2010的项目文件是完全兼容的,因此名称相同。 - habakuk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接