Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And let's emphasize the last line of the posting:

"The moral? Always use -Wall"



I always use "-W -Wall -ansi -pedantic". Substitute -std=c99 for -ansi if you swing that way. I then run my code through a couple of other static checkers just to see what comes up.

This frequently results in me finding some subtle bug which otherwise could have taken hours of head scratching or single-stepping in gdb to locate.


Yeah, I've been using "-Wall -Werror -Wstrict-prototypes -pedantic" as of late and I clearly need to start thinking about a -std or -ansi.

C is a somewhat weak foundation for static program analysis but that doesn't mean we can't try to make the most out of it.


"-Werror=implicit" would be more useful here. -Wall won't prevent that from compiling, but there's hardly any situation where you'd want it to compile.


Btw, is there a GCC specific way to disable warnings for some portions of code?


http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html should get you most of the way there.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: