Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I know I can compile individual source files, but sometimes -- say, when editing a header file used by many .cpp files -- multiple source files need to be recompiled. That's what Build is for.

Default behavior of the "Build" command in VC9 (Visual C++ 2008) is to attempt to compile all files that need it. Sometimes this just results in many failed compiles. I usually just watch for errors and hit ctrl-break to stop the build manually.

Is there a way to configure it such the build stops at the very first compile error (not the first failed project build) automatically?

like image 822
jwfearn Avatar asked Sep 25 '08 17:09

jwfearn


2 Answers

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.

like image 96
Eric Muyser Avatar answered Sep 22 '22 01:09

Eric Muyser


This can be done by adding a macro that is run in response to the event OnBuildProjConfigDone.

The macro is as follows:

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
like image 44
jmatthias Avatar answered Sep 20 '22 01:09

jmatthias