Clang warning flags for Objective-C development

Posted by Macmade on Programmers See other posts from Programmers or by Macmade
Published on 2011-11-28T20:09:08Z Indexed on 2011/12/01 2:18 UTC
Read the original article Hit count: 1175

Filed under:
|

As a C & Objective-C programmer, I'm a bit paranoid with the compiler warning flags.
I usually try to find a complete list of warning flags for the compiler I use, and turn most of them on, unless I have a really good reason not to turn it on.

I personally think this may actually improve coding skills, as well as potential code portability, prevent some issues, as it forces you to be aware of every little detail, potential implementation and architecture issues, and so on...

It's also in my opinion a good every day learning tool, even if you're an experienced programmer.

For the subjective part of this question, I'm interested in hearing other developers (mainly C, Objective-C and C++) about this topic.
Do you actually care about stuff like pedantic warnings, etc? And if yes or no, why?

Now about Objective-C, I recently completely switched to the LLVM toolchain (with Clang), instead of GCC.

On my production code, I usually set this warning flags (explicitly, even if some of them may be covered by -Wall):

  • -Wall
  • -Wbad-function-cast
  • -Wcast-align
  • -Wconversion
  • -Wdeclaration-after-statement
  • -Wdeprecated-implementations
  • -Wextra
  • -Wfloat-equal
  • -Wformat=2
  • -Wformat-nonliteral
  • -Wfour-char-constants
  • -Wimplicit-atomic-properties
  • -Wmissing-braces
  • -Wmissing-declarations
  • -Wmissing-field-initializers
  • -Wmissing-format-attribute
  • -Wmissing-noreturn
  • -Wmissing-prototypes
  • -Wnested-externs
  • -Wnewline-eof
  • -Wold-style-definition
  • -Woverlength-strings
  • -Wparentheses
  • -Wpointer-arith
  • -Wredundant-decls
  • -Wreturn-type
  • -Wsequence-point
  • -Wshadow
  • -Wshorten-64-to-32
  • -Wsign-compare
  • -Wsign-conversion
  • -Wstrict-prototypes
  • -Wstrict-selector-match
  • -Wswitch
  • -Wswitch-default
  • -Wswitch-enum
  • -Wundeclared-selector
  • -Wuninitialized
  • -Wunknown-pragmas
  • -Wunreachable-code
  • -Wunused-function
  • -Wunused-label
  • -Wunused-parameter
  • -Wunused-value
  • -Wunused-variable
  • -Wwrite-strings

I'm interested in hearing what other developers have to say about this.

For instance, do you think I missed a particular flag for Clang (Objective-C), and why?
Or do you think a particular flag is not useful (or not wanted at all), and why?

© Programmers or respective owner

Related posts about objective-c

Related posts about clang