Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

GCC 4.4.4 C99 EXTREME WARNING MODE

Name: Anonymous 2010-08-29 6:05

I want to compile a C99 program in GCC 4.4.4 but I want to do it in EXTREME WARNING MODE.

How do I do that?

Name: Anonymous 2010-08-30 15:51

Behold, my aclocal file (just put ENABLE_WARNINGS in configure.in and configure with --enable-warnings, or --enable-warnings=-Werror or whatever).  If you're not using autotools, then you're PROBABLY using something inferior.  Autotools sucks really hard, but still manages to suck less than SCons, Jam, CMake, or your favorite IDE.


AC_DEFUN([ENABLE_WARNINGS],[
  AC_ARG_ENABLE(warnings,
    [  --enable-warnings       enable warnings for GCC ],
    [enable_warnings=$enableval], [warnings=no])
  if test "x$enable_warnings" != xno ; then
    [warning_cflags="-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wchar-subscripts -Wredundant-decls -pedantic"]
    if test "x$enable_warnings" != xyes ; then
      [warning_cflags="$warning_cflags $enable_warnings"]
    fi
  fi
  AC_SUBST([warning_cflags])
])


The "-Wshadow" can be a bitch, I have to rename variables e.g. "index" because there is a standard library function named "index".

I used to use "-Wno-unused-parameter" but I turned it on and it caught some bugs so I leave it on now, and stick these in my code:


int always_returns_three(int x)
{
    (void)x;
    return 3;
}


It's ugly but my code DOES have less bugs now.

As an alternative, plug in "clang" for a bit.  It might spit out a bunch of new warnings, they'll often be pretty nice.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List