0

Is there any hope to force GCC 3.4 compiler to make all warnings into errors like GCC's 4.4 -Werror option does ?

Thanks

Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70

3 Answers3

1

You can wrap it and return an error if gcc wrote anything to stderr.

Execute GCC, redirect stderr in a file, cat the file to stderr:

temp=$(tempfile)
trap rm "$temp" EXIT

gcc "$@" 2>"$temp"
ret=$?

cat "$temp" >&2

Return gcc's exit status if it's not 0:

if [ "$ret" != 0 ]; then
    exit $ret;
}

Return 1 if the file is not empty:

if [ $(stat --format=%s "$temp") != "0" ]; then
    exit 1;
}
Arnaud Le Blanc
  • 98,321
  • 23
  • 206
  • 194
1

Ugly hack, just grep "warning:"

gcc files.c 2>&1 | grep "warning:" && exit 1

Replace exit 1 with what it should do when warnings are found.

Emil Romanus
  • 794
  • 1
  • 4
  • 8
0

As @pmg said -

gcc 3.4.6 accepts -Werror (see bottom of manual); gcc 3.3.6 also accepts it !!

Real credits should go to pmg, but thanks for everybody else also :-)

Agnius Vasiliauskas
  • 10,935
  • 5
  • 50
  • 70