AnsweredAssumed Answered

Problems with batch file not halting on error

Question asked by italiandoh on Jan 14, 2009
Latest reply on Feb 1, 2011 by italiandoh
I am using Codewarrior for Freescale MC9S12X family via batch file and not using the IDE.
I successfully created the batch file for compiling, linking and so on and it works OK, but with a problem. In case of a error during execution of compiler, the batch file in unable to detect this error and stop the process. This way we are forced to wait for the compilation of all files before stopping the process.
Of course we use the tool "Piper.exe" to capture the output of the various tools and save it to file and print it on screen.
Here's a sample of the batch file code :

for %%c in (%CTARGETS%) do (call %COMPILER_PATH%\piper.exe %COMPILER% %%c %COMPILER_OPTIONS%
                            IF %ERRORLEVEL% NEQ 0 goto error_label

We use this for loop in the batch file to compile all the *.c source code files. But it seems like that, in case of compiler errors, the ERRORLEVEL variable is not set, so the for loop is not interrupted.
I guess that the problem is that piper.exe does not report any errors even if chc12.exe returned them.
Has anyone experienced such a problem ?
If anyone knows a possible solution for this, please let me know.
Thanks in advance and best regards,