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

You can go further and specify a particular standard, plus extra warnings not included in -Wall:

    gcc -std=c99 -Wall -Wextra -Werror
I'm not sure if -pedantic is still beneficial in that case. The gcc documentation had a list of every warning category, and which parameters enable each warning. This SO question was also interesting: http://stackoverflow.com/questions/11714827/how-to-turn-on-l...


-std=cNN specifies the base language standard. Much existing code depends on GCC extensions to that standard (for better or for worse), so it is often necessary to use -std=gnuNN instead (specifying base language dialect + extensions).


A tiny comparison: -Wall -pedantic gives me:

  warning: C++ style comments are not allowed in ISO C90
  warning: ISO C90 forbids mixed declarations and code
-Wall -Wextra gives me:

   warning: unused parameter ‘type’
For me, -Wextra is much more useful for finding messy code.


Use both of them. The last warning is about messy code, but the first two will help you keep the code portable.


clang has -Weverything, which means, well, warn about everything.

Also —analyze to run the static analyzer: http://clang-analyzer.llvm.org


One of my professors in college wouldn't accept code that didn't compile with the invocation.

"Your compiler is trying to help you. Listen to it."




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

Search: