2010-04-24

I wish everyone put -Wall -Werror into CFLAGS in their Makefile(s)

Random geeky rant:

I wish everyone (especially people maintaining libraries for others to compile against) would use -Wall -Werror (and maybe even -pedantic and other such things) in their Makefiles for things. It's really quite simple, just find the line that looks like:

CFLAGS = -g # and/or whatever else

and add -Wall -Werror to the end of that, like:

CFLAGS = -g -Wall -Werror # and/or whatever else

Oh, and I've recently learned of another one, to enable "extra" warnings, and a nicer way to put them into your (GNU) Makefile:

CFLAGS += -Werror -Wall -Wextra

Get your compiler to force the issue of fixing your warnings, so someone else won't end up stuck with them. You know your code better than someone else will, so you'll be much better at finding the right fix to the warning.

I'd give extra bonus points to anyone adding these to default configurations (default option for gcc? Apple make these the default for Xcode, etc.). There might be downsides to that, but... oy. So many projects have so many warnings, many of which (though I'm sure not all) are likely bugs that could be fixed if people would warn about them.

[Note: this article was edited 2011-02-28 to add new content, and re-shape some of the existing content.]