Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: pozzugno on December 07, 2010, 03:38:11 pm

Title: A compiler that returns non-zero value with warnings
Post by: pozzugno on December 07, 2010, 03:38:11 pm
I have a compiler that exits with non-zero value when it detects warnings.
The build process of a project is stopped by CodeBlocks when a toolchain executable
returns a non-zero value (at least, it seems CodeBlocks behaves in this way).

Is there a solution to continue the compilation process even if the compiler exits
with non-zero value?
Title: Re: A compiler that returns non-zero value with warnings
Post by: oBFusCATed on December 07, 2010, 04:28:18 pm
You can wrap the compiler executable in shell script or batch file with returns 0.
Then tell C::B to use the script/batch file.

I've never tried such thing, so I'm not 100% sure it will work...
Title: Re: A compiler that returns non-zero value with warnings
Post by: Jenna on December 08, 2010, 07:23:16 am
You can wrap the compiler executable in shell script or batch file with returns 0.
Then tell C::B to use the script/batch file.

I've never tried such thing, so I'm not 100% sure it will work...
At least on linux it works (I do this to wrap ccache).
Title: Re: A compiler that returns non-zero value with warnings
Post by: pozzugno on December 14, 2010, 09:49:18 am
You can wrap the compiler executable in shell script or batch file with returns 0.
Then tell C::B to use the script/batch file.

I'm using C::B under Windows XP. If I launch the compiler and it produces warnings, it
returns value 1. Can you confirm C::B stops compiling when the compiler returns with
a non-zero value?

At the shell prompt I tried with this command:
> mycomp -c main.c -o main.obj & if errorlevel 1 ver
I use the CMD.EXE shell facilities to execute two commands: "mycomp" and "if".
errorlevel is the return value of the last executed command (in my case it's mycomp).
If the return value of mycomp is 1, I run the command ver (that outputs the version
of the shell) just to have a command that returns zero.

I changed the "Command line macro" in Advacend Settings in the following way:
  $compiler $options -o $object $file & if errorlevel 1 ver
but the compilation doesn't work because "& if errorlevel 1 ver" are passed to the
compiler as other parameters and not as shell new command to execute after the
compiler.

Is the batch script the only solution?
Title: Re: A compiler that returns non-zero value with warnings
Post by: oBFusCATed on December 14, 2010, 10:35:32 am
No, you can modify the C::B sources :P

BTW: There is an exit command (or something like that). You can use it to change the exit code of a batch script. No need to do the hacks with the version command.
Title: Re: A compiler that returns non-zero value with warnings
Post by: pozzugno on December 14, 2010, 05:26:06 pm
No, you can modify the C::B sources :P

BTW: There is an exit command (or something like that). You can use it to change the exit code of a batch script. No need to do the hacks with the version command.

Thank you, I created the batch script and now it works.