Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
cl.exe returns zero for success (no errors) and non-zero otherwise.
The return value of cl.exe can be useful if you are compiling from a script, or .bat file. You should still plan to capture the output of the compiler, in case there are errors or warnings, so you can resolve them.
Remarks
The following is a sample .bat file that uses the return value of cl.exe.
echo off
cl /W4 t.cpp
@if ERRORLEVEL == 0 (
goto good
)
@if ERRORLEVEL != 0 (
goto bad
)
:good
echo "clean compile"
echo %ERRORLEVEL%
goto end
:bad
echo "error or warning"
echo %ERRORLEVEL%
goto end
:end