Automatically stop Visual C++ 2008 build at first compile error?

I came up with a better macro guys. It stops immediately after the first error/s (soon as build window is updated).

Visual Studio -> Tools -> Macros -> Macro IDE… (or 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 

Hope it works out for you guys.

Leave a Comment