[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cmd.exe /c exists because of a compilation error transmitted by gnum

From: Paul D. Smith
Subject: Re: cmd.exe /c exists because of a compilation error transmitted by gnumake to the shell
Date: Fri, 24 Feb 2006 00:14:15 -0500

%% Cedric Perthuis <address@hidden> writes:

  cp> "cmd.exe /c gnumake && pause"

  cp> if the build succeeds then my cmd.exe window will be left open on
  cp> the build server waiting for someone to press a key.

  cp> However, if the build fails: with a message like this one:
  cp> "main.cpp
  cp> win32\main.cpp(32) : fatal error C1083: Cannot open include file: 
  cp> 'Rapi.h': No such file or directory
  cp> gnumake: *** [../../tmp/win32/Debug/emviewer/win32/main.obj] Error 2"
  cp> then the command "pause" is not executed.

That's because "&&" means "and"; that is, the second command is only run
if the first command is true.  If the first command is false, then the
expression is definitely false and the second command does not need to
be run; this is a "short-circuiting AND" operator, just like in C.

  cp> The thing here is that my build command is completely valid, the fact 
  cp> that the build fails is something else, that I want to handle myself.
  cp> so is there a way to configure gnumake not to output an error which 
  cp> makes cmd.exe to exit ?

Make will always exit with an error if one of its commands fails, unless
the command is prefixed with a "-" (to ignore the failure).  But if you
do that then targets that depend on the failed target will still be
built and presumably those will fail, etc. etc.

The simplest thing to do is just not use "&&", so that the "pause" is
always executed regardless of the exit code of GNU make.

I don't know much about Windows scripting but in UNIX shells you could
just write "gnumake ; read val" and the "read" (does basically what your
pause does) would always be invoked regardless of the exit code of make.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

[Prev in Thread] Current Thread [Next in Thread]