On May 29, 2009, at 11:22 PM, Graham Cox wrote:
Is there a way to tune xCode so that it warns you of these types of potential problems (and more)? The Java development environment I've been using for the past several years (Jetbrains IDEA) has unbelievably fantastic code-editing and compile-time warning systems that allow you to show a myriad of situations as warnings (some are user definable). Is there a way to do this in xCode, or at least set some flags to get more verbose warnings (especially those that can prevent "dumb" mistakes)?
In your project's build settings, scroll down to "Other Warning Flags", and paste this lot in:

-Wall -Wcast-align -Wchar-subscripts -Wextra -Wextra-tokens - Wformat=2 -Wmissing-field-initializers -Wpointer-arith -Wshadow - Wswitch-default -Wundef -Wwrite-strings

I'm not immediately sure what they all do, but that's what I compile with (cleanly).


Nice list, Graham :).

It's important to note that the original question, warning about uninitialized automatic variables, is only possible in GCC when optimization is turned on. From Xcode's research assistant for that particular setting (emphasis mine):

--
Warn if a variable might be clobbered by a setjmp call or if an automatic variable is used without prior initialization.

***Detection of uninitialized automatic variable requires data flow analsys that is only enabled during optimized compilation.***

Note that GCC cannot detect all cases where an automatic variable is initialized or all usage patterns that may lead to use prior to initialization.
--

In short, you can't get this warning in a Debug-style build unless you want to sabotage your debugging efforts by adding optimization.

-- Gwynne

_______________________________________________

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