News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

A compiler that returns non-zero value with warnings

Started by pozzugno, December 07, 2010, 03:38:11 PM

Previous topic - Next topic

pozzugno

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?

oBFusCATed

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...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Jenna

Quote from: 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...
At least on linux it works (I do this to wrap ccache).

pozzugno

Quote from: 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'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?

oBFusCATed

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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

pozzugno

Quote from: 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.

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