GNU pause. Make in the Windows console if an error occurs.

Part of the setup for the application for which I am responsible is compiling some C code libraries. This is done on the console using GNU Make.

So, as part of the installation, the console window opens, you see the output of the make wiz file as it compiles and references, when you finish the console window closes, and the installation program continues.

All is well if there is no compilation error. Then an error occurs in the make file and the console window closes before you can figure out what is happening.

So, I would like the console window to be paused using the "press the key to continue" function if there is an error in the makefile so that the console remains open. Otherwise, just log out as usual and close the console.

I cannot figure out how to do this in the GNU Makefile or from a batch file that Make can run.

+5
source share
4 answers

this should do the trick:

if not ERRORLEVEL 0 pause

type help ifin DOS for more information on using the error level.

+9
source

This is what you are looking for:

if ERRORLEVEL 1 pause

If you type

HELP IF

: ERRORLEVEL | , , .

+2
0

C :

#include <stdio.h>
main(int argc, char *argv[]) {
    if (argc == 2) {
        // return integer of argument 1
        return strtol(argv[1], NULL, 10);
    }
    else {
        return 0;
    }
}

:

test.exe 0
IF ERRORLEVEL 0 PAUSE

: 0 => 0 == TRUE

ERRORLEVEL = 0, , >= . , , ==.

, 1 => 0 , , , . .

, 0:

test.exe -1
IF ERRORLEVEL 0 PAUSE

: -1 => 0 == FALSE

ERRORLEVEL of 1 , , 0 , , , :

test.exe 0
IF ERRORLEVEL 1 PAUSE

: -1 => 1 == FALSE

: 0 => 1 == FALSE

: 1 => 1 == TRUE

. script , ERRORLEVEL 1

, -1 , 0. , 0 ? :

test.exe 0
IF NOT %ERRORLEVEL% EQU 0 PAUSE

: -1 != 0 == TRUE

: 0 != 0 == FALSE

: 1 != 0 == TRUE

script , %ERRORLEVEL% 0 , EQU, , %ERRORLEVEL% EQU 0, NOT , !=. , , NT, DOS.

:

http://chrisoldwood.blogspot.ca/2013/11/if-errorlevel-1-vs-if-errorlevel-neq-0.html http://ss64.com/nt/errorlevel.html

0

All Articles