Author Topic: A compiler that returns non-zero value with warnings  (Read 5444 times)

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
A compiler that returns non-zero value with warnings
« 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: A compiler that returns non-zero value with warnings
« Reply #1 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...
(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!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: A compiler that returns non-zero value with warnings
« Reply #2 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).

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: A compiler that returns non-zero value with warnings
« Reply #3 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?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: A compiler that returns non-zero value with warnings
« Reply #4 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.
(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!]

Offline pozzugno

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: A compiler that returns non-zero value with warnings
« Reply #5 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.