Alex Rivera | Logout

Recommended GCC warning options for C

Asked 2008-09-30T19:42:35.643
89

Other than -Wall, what other warnings have people found useful?

Options to Request or Suppress Warnings

Edit
Report

4 Answers

2

Right now I use:

-Wall -W -Wextra -Wconversion -Wshadow -Wcast-qual -Wwrite-strings -Werror

I took that list mostly from the book "An Introduction to GCC" (by rms) and then some from Ulrich Drepper's recommendation about defensive programming (slides for Defensive Programming).

But I don't have any science behind my list. It just felt like a good list.


Note: I don't like those pedantic flags though...

Note: I think that -W and -Wextra are more or less the same thing.

answered 2009-03-21T13:07:31.853
1
answered 2008-09-30T20:30:40.970
1

The warning about uninitialized variables doesn't work unless you specify -O, so I include that in my list:

-g -O -Wall -Werror -Wextra -pedantic -std=c99

Documentation on each warning:

answered 2009-11-03T12:28:28.623

Your Answer