Thanks for that list.

Regarding your choice of

        GCC_WARN_UNUSED_PARAMETER = YES

How do you get around the fact that you often get warnings for delegate methods you are forced to implement where you don't ever use given parameter(s)? Do you use a "#pragma GCC diagnostic ignored ..." to skip that warning for the given file, or do you reference all parameters in some bogus way to avoid the warning, or...?

- Eric


On May 30, 2009, at 11:48 AM, Alex Curylo wrote:


On 30-May-09, at 8:14 AM, cocoa-dev-requ...@lists.apple.com wrote:

Is there a way to tune xCode so that it warns you of these types of
potential problems (and more)?

Here's what I've got in my standard base .xcconfig right now.

// C Only Warnings
TW_GENERAL_OTHER_CFLAGS = -Wdiv-by-zero -Wbad-function-cast -Wnested- externs -Wold-style-definition

// C++ Only Warnings
TW_GENERAL_OTHER_CPLUSPLUSFLAGS = -Wabi -Wctor-dtor-privacy -Wstrict- null-sentinel -Wsign-promo
GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES

// General C/C++/ObjC/ObjC++ warnings
TW_GENERAL_WARNING_CFLAGS1 = -Wall -Wendif-labels -Winvalid-pch - Wformat=2 -Wmissing-format-attribute -Wwrite-strings -Wstack- protector -Wstrict-aliasing=2
TW_GENERAL_WARNING_CFLAGS2 = -Wpacked -Wmissing-field-initializers
TW_GENERAL_WARNING_CFLAGS3 = -Wextra -Wpointer-arith -Wdisabled- optimization -Wfloat-equal TW_GENERAL_WARNING_CFLAGS = $(TW_GENERAL_WARNING_CFLAGS1) $ (TW_GENERAL_WARNING_CFLAGS2) $(TW_GENERAL_WARNING_CFLAGS3)

// GCC_WARN_UNINITIALIZED_AUTOS is defined in the release/debug xcconfigs.
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_MISSING_PARENTHESES = YES
GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES
GCC_WARN_UNKNOWN_PRAGMAS = YES
GCC_WARN_UNUSED_LABEL = YES
GCC_WARN_UNUSED_FUNCTION = YES
GCC_WARN_UNUSED_VALUE = YES
GCC_WARN_UNUSED_VARIABLE = YES
GCC_WARN_UNUSED_PARAMETER = YES
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_SHADOW = YES
GCC_WARN_SIGN_COMPARE = YES

GCC_WARN_PEDANTIC = NO // doesn't even like #import
GCC_WARN_PROTOTYPE_CONVERSION = NO // may catch implicit casts, but lots of noise ... like YES and NO for BOOL
GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = NO

// merge flag/path settings with possible previous configuration file flag settings

WARNING_CFLAGS = $(inherited) $(TW_GENERAL_WARNING_CFLAGS) $ (TW_CONFIGURATION_WARNING_CFLAGS) OTHER_CFLAGS = $(inherited) $(TW_GENERAL_OTHER_CFLAGS) $ (TW_CONFIGURATION_OTHER_CFLAGS) // note that OTHER_CPLUSPLUSFLAGS does *not* inherit -- default is $ (OTHER_CFLAGS) and we want these separated OTHER_CPLUSPLUSFLAGS = $(TW_GENERAL_OTHER_CPLUSPLUSFLAGS) $ (TW_CONFIGURATION_OTHER_CPLUSPLUSFLAGS) GCC_PREPROCESSOR_DEFINITIONS = $(inherited) $ (TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS)
OTHER_LDFLAGS = $(inherited) $(TW_CONFIGURATION_OTHER_LDFLAGS)

A standard debug .xcconfig adds

TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1

GCC_OPTIMIZATION_LEVEL = 0
GCC_WARN_UNINITIALIZED_AUTOS = NO

and a standard release .xcconfig

TW_CONFIGURATION_GCC_PREPROCESSOR_DEFINITIONS = NDEBUG=1

GCC_OPTIMIZATION_LEVEL = s
GCC_WARN_UNINITIALIZED_AUTOS = YES

GCC_TREAT_WARNINGS_AS_ERRORS = YES

// -Wno-unused-parameter needed because of "unused parameter 'value'" garbage from @synthesize in gcc 4.0
// init-self can only be turned on when optimizations are on
TW_CONFIGURATION_WARNING_CFLAGS = -Wno-unused-parameter -Winit-self



I find that basically nothing ever slips through this level of code hygiene. YMMV.

If you wish to be even more OCD about it than this, peruse

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

http://gcc.gnu.org/onlinedocs/gcc/Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html

The strategy above is cribbed pretty much directly from the Google Toolbox for Mac .xcconfig stuff, so you may want to grab the latest version of that as well and see if they've made any significant updates since I put this together.

--
Alex Curylo -- a...@alexcurylo.com -- http://www.alexcurylo.com/

You know you've had a good night when you wake up
and someone's outlining you in chalk.



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/zmonster%40mac.com

This email sent to zmons...@mac.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to