3 ms·
The compiler flags for Ag[1] are rather strict these days: -Wall -Wextra -Wformat=2 -Wno-format-nonliteral -Wshadow \ -Wpointer-arith -Wcast-qual -Wmis
by ggreer 13y 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 https://github.com/ggreer/the_silver_searcher
2. http://clang-analyzer.llvm.org/scan-build.html http://clang-analyzer.llvm.org/scan-build.html
3. http://clang.llvm.org/docs/ClangFormat.html http://clang.llvm.org/docs/ClangFormat.html
- fafner 13y ago-pedantic-errors is also a very useful flag. -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.
- astrange 13y agogcc's -Wstrict-aliasing is extremely inaccurate. It doesn't run inside the aliasing machinery; it's just a cheap heuristic inside the C parser. I'd call it a good example of why you shouldn't strive to fix a warning just because it happens to exist. I thought there was a better tool, but can't find the name, hmm.
- abrahamsen 13y agoI really wish for a -Weverything flags that would enable all warnings, even the stupid, useless ones. I'd then put -Wno-<stupid, useless warning> to disable those.
- cammsaul 13y agoclang has -Weverything, I prefer to start with that and do #pragma clang diagnostic push/ignored/pop as needed and only turn off the really obnoxious ones, like -W-c++98-compat-pedantic
- saosebastiao 13y agoUpvote for the completely off-topic reason of having written one of the most amazingly useful tools I have ever touched.