我知道我可以编译单个源文件,但有时--比方说,在编辑许多.cpp
文件使用的头文件时--需要重新编译多个源文件。这就是构建的目的。
在VC9 (Visual C++ 2008)中,"Build“命令的默认行为是尝试编译所有需要它的文件。有时,这只会导致许多编译失败。我通常只是观察错误,然后按ctrl-break手动停止构建。
有没有办法配置它,使构建在第一次编译错误(而不是第一次失败的项目构建)时自动停止?
发布于 2009-07-06 03:03:53
我想出了一个更好的宏观家伙。它在出现第一个错误后立即停止(构建窗口更新后立即停止)。
Visual Studio ->工具->宏->宏集成开发环境...(或ALT+F11)
Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdated
If Not (pPane.Name = "Build") Then Exit Sub
pPane.TextDocument.Selection.SelectAll()
Dim Context As String = pPane.TextDocument.Selection.Text
pPane.TextDocument.Selection.EndOfDocument()
Dim found As Integer = Context.IndexOf(": error ")
If found > 0 Then
DTE.ExecuteCommand("Build.Cancel")
End If
End Sub
希望你们能行得通。
发布于 2008-10-11 22:30:57
这可以通过添加为响应event OnBuildProjConfigDone而运行的宏来完成。
宏如下所示:
Private Sub BuildEvents_OnBuildProjConfigDone(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String, ByVal Success As Boolean) Handles BuildEvents.OnBuildProjConfigDone
If Success = False Then
DTE.ExecuteCommand("Build.Cancel")
End If
End Sub
发布于 2011-01-21 18:20:39
是的,这在MSVC 2005-2010上运行得很好:
Public Module EnvironmentEvents
Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdated
If Not (pPane.Name = "Build") Then Exit Sub
Dim foundError As Boolean = pPane.TextDocument.StartPoint.CreateEditPoint().FindPattern(": error")
Dim foundFatal As Boolean = pPane.TextDocument.StartPoint.CreateEditPoint().FindPattern(": fatal error")
If foundError Or foundFatal Then
DTE.ExecuteCommand("Build.Cancel")
End If
End Sub
End Module
https://stackoverflow.com/questions/134796
复制相似问题