|
|
|
|
|
by ggreer
4478 days ago
|
|
The compiler flags for Ag[1] are rather strict these days: -Wall -Wextra -Wformat=2 -Wno-format-nonliteral -Wshadow \
-Wpointer-arith -Wcast-qual -Wmissing-prototypes -Wno-missing-braces \
-std=gnu89 -D_GNU_SOURCE -O2
Note that -Wall and -Wextra do not enable all warnings. To keep backwards compatibility, -Wall is basically, "All warnings as of 1990." -Wextra covers a lot of the newer warnings, but still misses a few.I also use scan-build[2] for static analysis and clang-format[3] to ensure a consistent style. It was frustrating when I first enabled all these options, but the warnings helped me discover bugs that had been lurking for years. 1. https://github.com/ggreer/the_silver_searcher 2. http://clang-analyzer.llvm.org/scan-build.html 3. http://clang.llvm.org/docs/ClangFormat.html |
|
-Wstrict-aliasing=1/-Wsuggest-attribute= can give good suggestions during development.
Probably not useful for Ag: But I do a lot of numeric stuff so -Wfloat-equal is handy for me. For code using float this should be mandatory: -Wdouble-promotion.