为什么 Visual Studio 不显示 #warning 指令 (CS1030) 生成的警告?
UPD:该错误似乎已在 VS 2012 中修复。
编辑:我将此作为 Microsoft Connect 站点上的错误报告此处(该页面已被删除)。
编辑2:微软不会修复这个bug(至少在VS2010中不会)。
对于每个项目的一个文件,用户定义的警告仅显示在“错误列表”窗口中。 因此,如果您将 #warning 指令放入项目的多个文件中,则大多数文件在构建后将不会看到任何警告。 缺少的警告由 msbuild 生成,可以在“输出”窗口中看到,但在“错误列表”窗口中看不到。
注意:包含 #warning 的文件都必须在构建时在 VS 编辑器中打开才能看到此效果(VS bug?)。
如何在构建时显示所有用户定义的警告?
我使用的是 Visual Studio 2008 SP1。
UPD: The bug seems to have been fixed in VS 2012.
Edit: I reported this as a bug on the Microsoft Connect site here (the page has been removed).
Edit 2: Microsoft will not fix this bug (at least not in VS2010).
User defined warnings are only shown in the Error List window for one file per project. So if you put the #warning directive in several files of your project, you will not see any warnings after build for most of the files. The missing warnings are generated by msbuild and can be seen in the Output window, but not in the Error List window.
Note: none of the files containing #warning's must be open in VS editor on the moment of build for this effect (a VS bug?) to be seen.
How do I get all of my user-defined warnings displayed on build?
I'm using Visual Studio 2008 SP1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我自己做了一个小实验。
在这种情况下,任务列表仅显示其中一个错误。 但是,如果您查看输出窗口,它会在编译时显示两个错误。
任务列表中只显示一个错误,听起来像是一个错误。 您能否在 connect 上提交此问题?
I did a little experiment of my own.
In this case the task list only shows one of the errors. However if you look at the output window it shows both errors while compiling.
The displaying of only one error in the task list smells like a bug. Could you please file this issue on connect?
你还没有说出你想要完成什么,只是如何你想要完成它。
不过,请查看是否错误消息在源代码中突出显示可以帮助您解决任何问题。
You haven't said what you're trying to accomplish, only how you're trying to accomplish it.
Still, see if Error message highlighting in source code helps you out any.