<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Warnings I turn on, and why</title>
	<atom:link href="http://boredzo.org/blog/archives/2009-11-07/warnings/feed" rel="self" type="application/rss+xml" />
	<link>http://boredzo.org/blog/archives/2009-11-07/warnings</link>
	<description>The personal weblog of Peter Hosey.</description>
	<lastBuildDate>Mon, 15 Mar 2010 23:31:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Sean M</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-304649</link>
		<dc:creator>Sean M</dc:creator>
		<pubDate>Wed, 03 Mar 2010 22:29:27 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-304649</guid>
		<description>I once spent quite some time trying to enable as many warnings as possible by scouring the gcc man page.  Below is my .xcconfig file that contains various warning flags.  When Xcode has a specific option for a warning, I use it, if it doesn&#039;t exist I use the gcc flag. Note that some warnings do/don&#039;t work with some compilers.  Our large Obj-C/Obj-C++ app builds warning-free with these settings. (RR is our company prefix, BW stands for Build Warning). This assumes gcc 4.2 and Xcode 3.2. Hope it&#039;s helpful.
 
&lt;pre&gt;// C only warnings.
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
RR_BW_C_NOTCLANG = -Wdiv-by-zero
RR_BW_C = -Wstrict-prototypes -Wold-style-definition -Wnested-externs -Wmissing-prototypes -Wmissing-declarations $(RR_BW_C_NOTCLANG)
OTHER_CFLAGS = $(RR_BW_C)

// C++ only warnings.
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
RR_BW_CPP = -Wabi -Wctor-dtor-privacy -Wsign-promo -Woverloaded-virtual
OTHER_CPLUSPLUSFLAGS = $(RR_BW_CPP)

// Objective C only.
GCC_WARN_STRICT_SELECTOR_MATCH = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
RR_BW_OBJC = 

// For all C-based languages.
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES
GCC_WARN_SHADOW = YES
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_MISSING_PARENTHESES = YES
GCC_WARN_SIGN_COMPARE = YES
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES

// Managed Object Model compiler.
MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS = YES

// Note that it is important to start with -Wall and -Wextra because if they were at the end, they may reset some other options.
RR_BW_ALL_NOTCLANG = -Wlarger-than-30000 -Winvalid-pch
RR_BW_ALL_NOTGCC40 = -Wstrict-overflow=2 -Wvolatile-register-var -fdiagnostics-show-option
RR_BW_ALL = -Wall -Wextra -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-format-nonliteral -Wmissing-format-attribute -Wpacked -Wredundant-decls -Wdisabled-optimization -Wno-strict-aliasing -Wfloat-equal -Winit-self -Wextra-tokens -Wmissing-field-initializers $(RR_BW_ALL_NOTGCC40) $(RR_BW_ALL_NOTCLANG)

// Warnings to enable occasionally.  They give some good warnings, but not always.
//GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES
//RR_BW_ALL_OCCASIONAL = -Wcast-qual -Wunsafe-loop-optimizations -funsafe-loop-optimizations -Wswitch-enum -Wstack-protector -Wformat-nonliteral

// Combine.
WARNING_CFLAGS = $(RR_BW_ALL) $(RR_BW_OBJC)

// TODO: would like to use:
//  GCC_WARN_PEDANTIC = YES • too annoying with Obj-C
//  -Wcast-qual • gives false positives with Obj-C 4625600. But turn on periodically, as it finds real problems!
//  -Wstrict-aliasing • is unnecessarily annoying 5509903 5509977
//  -Wstrict-aliasing=2 would be even nicer, though it is documented to give false positives
//  -Wformat-nonliteral (part of -Wformat=2) • causes problems with NSLocalizedStringFromTable 6835692
&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>I once spent quite some time trying to enable as many warnings as possible by scouring the gcc man page.  Below is my .xcconfig file that contains various warning flags.  When Xcode has a specific option for a warning, I use it, if it doesn't exist I use the gcc flag. Note that some warnings do/don't work with some compilers.  Our large Obj-C/Obj-C++ app builds warning-free with these settings. (RR is our company prefix, BW stands for Build Warning). This assumes gcc 4.2 and Xcode 3.2. Hope it's helpful.</p>
<pre>// C only warnings.
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES
RR_BW_C_NOTCLANG = -Wdiv-by-zero
RR_BW_C = -Wstrict-prototypes -Wold-style-definition -Wnested-externs -Wmissing-prototypes -Wmissing-declarations $(RR_BW_C_NOTCLANG)
OTHER_CFLAGS = $(RR_BW_C)

// C++ only warnings.
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES
GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = YES
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES
RR_BW_CPP = -Wabi -Wctor-dtor-privacy -Wsign-promo -Woverloaded-virtual
OTHER_CPLUSPLUSFLAGS = $(RR_BW_CPP)

// Objective C only.
GCC_WARN_STRICT_SELECTOR_MATCH = YES
GCC_WARN_UNDECLARED_SELECTOR = YES
RR_BW_OBJC = 

// For all C-based languages.
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES
GCC_WARN_SHADOW = YES
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES
GCC_WARN_MISSING_PARENTHESES = YES
GCC_WARN_SIGN_COMPARE = YES
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES
GCC_WARN_ABOUT_RETURN_TYPE = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES

// Managed Object Model compiler.
MOMC_NO_INVERSE_RELATIONSHIP_WARNINGS = YES

// Note that it is important to start with -Wall and -Wextra because if they were at the end, they may reset some other options.
RR_BW_ALL_NOTCLANG = -Wlarger-than-30000 -Winvalid-pch
RR_BW_ALL_NOTGCC40 = -Wstrict-overflow=2 -Wvolatile-register-var -fdiagnostics-show-option
RR_BW_ALL = -Wall -Wextra -Wundef -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wformat=2 -Wno-format-nonliteral -Wmissing-format-attribute -Wpacked -Wredundant-decls -Wdisabled-optimization -Wno-strict-aliasing -Wfloat-equal -Winit-self -Wextra-tokens -Wmissing-field-initializers $(RR_BW_ALL_NOTGCC40) $(RR_BW_ALL_NOTCLANG)

// Warnings to enable occasionally.  They give some good warnings, but not always.
//GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES
//RR_BW_ALL_OCCASIONAL = -Wcast-qual -Wunsafe-loop-optimizations -funsafe-loop-optimizations -Wswitch-enum -Wstack-protector -Wformat-nonliteral

// Combine.
WARNING_CFLAGS = $(RR_BW_ALL) $(RR_BW_OBJC)

// TODO: would like to use:
//  GCC_WARN_PEDANTIC = YES • too annoying with Obj-C
//  -Wcast-qual • gives false positives with Obj-C 4625600. But turn on periodically, as it finds real problems!
//  -Wstrict-aliasing • is unnecessarily annoying 5509903 5509977
//  -Wstrict-aliasing=2 would be even nicer, though it is documented to give false positives
//  -Wformat-nonliteral (part of -Wformat=2) • causes problems with NSLocalizedStringFromTable 6835692
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Mitchell</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-296886</link>
		<dc:creator>Jonathan Mitchell</dc:creator>
		<pubDate>Wed, 09 Dec 2009 14:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-296886</guid>
		<description>Personally I like the unused parameter warning.

Yes, it creates, a log of pragma clutter, especially for callbacks, but when reviewing code I find that those pesky pragmas do provide a bit of instant feedback that  would otherwise escape me.

The Apple docs on warnings are helpful too.
http://developer.apple.com/tools/xcode/compilercodewarnings.html

Good post.</description>
		<content:encoded><![CDATA[<p>Personally I like the unused parameter warning.</p>
<p>Yes, it creates, a log of pragma clutter, especially for callbacks, but when reviewing code I find that those pesky pragmas do provide a bit of instant feedback that  would otherwise escape me.</p>
<p>The Apple docs on warnings are helpful too.<br />
<a href="http://developer.apple.com/tools/xcode/compilercodewarnings.html" rel="nofollow">http://developer.apple.com/tools/xcode/compilercodewarnings.html</a></p>
<p>Good post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uli Kusterer</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-296221</link>
		<dc:creator>Uli Kusterer</dc:creator>
		<pubDate>Tue, 01 Dec 2009 09:19:52 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-296221</guid>
		<description>The Four-Character Literals warning isn&#039;t completely pointless. Since they&#039;re essentially an Apple addition to C, you want that warning turned on in cross-platform code. So, I wouldn&#039;t say &quot;for no benefit&quot;, I&#039;d say &quot;I&#039;m writing Mac-only code, so don&#039;t need it.&quot;</description>
		<content:encoded><![CDATA[<p>The Four-Character Literals warning isn't completely pointless. Since they're essentially an Apple addition to C, you want that warning turned on in cross-platform code. So, I wouldn't say "for no benefit", I'd say "I'm writing Mac-only code, so don't need it."</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ahruman</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-295968</link>
		<dc:creator>Ahruman</dc:creator>
		<pubDate>Sat, 28 Nov 2009 17:18:04 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-295968</guid>
		<description>I habitually set “-Wall -Wextra -Wno-unused-parameter” in Other Warning Flags, and turn on Treat Warnings as Errors (or -Werror if you like to copy and paste). The only downside is I sometimes need to deal with other people’s code. :-)</description>
		<content:encoded><![CDATA[<p>I habitually set “-Wall -Wextra -Wno-unused-parameter” in Other Warning Flags, and turn on Treat Warnings as Errors (or -Werror if you like to copy and paste). The only downside is I sometimes need to deal with other people’s code. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Uli Kusterer</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294588</link>
		<dc:creator>Uli Kusterer</dc:creator>
		<pubDate>Mon, 09 Nov 2009 15:39:14 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294588</guid>
		<description>Re: Treat Warnings as Errors:

If you can use that, do it. But I can&#039;t use that in most of my shipping projects, because they need to build and run on several platforms (10.4, 10.5, 10.6 ATM), and Apple&#039;s been madly changing their compilers with each version of Xcode, so I get warnings about settings that used to be necessary to build correctly, and are now deprecated, that would stop the build immediately :-(</description>
		<content:encoded><![CDATA[<p>Re: Treat Warnings as Errors:</p>
<p>If you can use that, do it. But I can't use that in most of my shipping projects, because they need to build and run on several platforms (10.4, 10.5, 10.6 ATM), and Apple's been madly changing their compilers with each version of Xcode, so I get warnings about settings that used to be necessary to build correctly, and are now deprecated, that would stop the build immediately :-(</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake C.</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294547</link>
		<dc:creator>Blake C.</dc:creator>
		<pubDate>Mon, 09 Nov 2009 04:29:16 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294547</guid>
		<description>Peter: That&#039;s better than editing all of those settings for each project, but you make a good point. I&#039;d say file a bug :)</description>
		<content:encoded><![CDATA[<p>Peter: That's better than editing all of those settings for each project, but you make a good point. I'd say file a bug :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christopher Lloyd</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294536</link>
		<dc:creator>Christopher Lloyd</dc:creator>
		<pubDate>Mon, 09 Nov 2009 02:11:18 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294536</guid>
		<description>&quot;Multiple Definition Types for Selector&quot; is only relevant for the GNU Objective-C runtime which has the mis-feature of trying to associate types with a selector. Largely pointless these days, should probably be deprecated all together.</description>
		<content:encoded><![CDATA[<p>"Multiple Definition Types for Selector" is only relevant for the GNU Objective-C runtime which has the mis-feature of trying to associate types with a selector. Largely pointless these days, should probably be deprecated all together.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294534</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Mon, 09 Nov 2009 01:03:08 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294534</guid>
		<description>Blake: That still requires copying the configuration file(s) into every project directory and configuring every project to use them.</description>
		<content:encoded><![CDATA[<p>Blake: That still requires copying the configuration file(s) into every project directory and configuring every project to use them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesper</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294529</link>
		<dc:creator>Jesper</dc:creator>
		<pubDate>Sun, 08 Nov 2009 23:38:58 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294529</guid>
		<description>dave: Select either your entire project (the blueprint icon at the top) or a specific target in the Groups &amp; Files list in your Xcode project, then choose Get Info from the right click menu. You change these settings on the Build tab; just watch out for the selected Configuration at the top.

For more information, see http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/A_Tour_of_Xcode/010-Xcode_Features_Overview/FeaturesTake2.html#//apple_ref/doc/uid/TP30000890-CH220-SW17 . That whole document (&quot;A Tour of Xcode&quot;) is worth reading since you&#039;re new to it.</description>
		<content:encoded><![CDATA[<p>dave: Select either your entire project (the blueprint icon at the top) or a specific target in the Groups &amp; Files list in your Xcode project, then choose Get Info from the right click menu. You change these settings on the Build tab; just watch out for the selected Configuration at the top.</p>
<p>For more information, see <a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/A_Tour_of_Xcode/010-Xcode_Features_Overview/FeaturesTake2.html#//apple_ref/doc/uid/TP30000890-CH220-SW17" rel="nofollow">http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/A_Tour_of_Xcode/010-Xcode_Features_Overview/FeaturesTake2.html#//apple_ref/doc/uid/TP30000890-CH220-SW17</a> . That whole document ("A Tour of Xcode") is worth reading since you're new to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dave</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294524</link>
		<dc:creator>dave</dc:creator>
		<pubDate>Sun, 08 Nov 2009 22:06:23 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294524</guid>
		<description>I&#039;m a bit of an xcode noob, so forgive my noobishness...
How do I change these settings?  I found references to some of them in the xcode build settings reference, not sure where to go from here.</description>
		<content:encoded><![CDATA[<p>I'm a bit of an xcode noob, so forgive my noobishness...<br />
How do I change these settings?  I found references to some of them in the xcode build settings reference, not sure where to go from here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake C.</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294521</link>
		<dc:creator>Blake C.</dc:creator>
		<pubDate>Sun, 08 Nov 2009 21:32:24 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294521</guid>
		<description>Peter and Amagrammer, you can do that with xcconfig files:

http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html

Look for the &quot;Build Configuration Files&quot; section.</description>
		<content:encoded><![CDATA[<p>Peter and Amagrammer, you can do that with xcconfig files:</p>
<p><a href="http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html" rel="nofollow">http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/XcodeBuildSystem/400-Build_Configurations/build_configs.html</a></p>
<p>Look for the "Build Configuration Files" section.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294500</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Sun, 08 Nov 2009 15:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294500</guid>
		<description>julian: No idea.

Amagrammer: Nope. Every “New” project is actually a copy of a project template, with a few variables (e.g., product name) replaced with values. You would have to change the templates, or create new ones.</description>
		<content:encoded><![CDATA[<p>julian: No idea.</p>
<p>Amagrammer: Nope. Every “New” project is actually a copy of a project template, with a few variables (e.g., product name) replaced with values. You would have to change the templates, or create new ones.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amagrammer</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294494</link>
		<dc:creator>Amagrammer</dc:creator>
		<pubDate>Sun, 08 Nov 2009 15:39:33 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294494</guid>
		<description>Thanks for the quick response.  Now maybe you can tell me: is there a way to make those settings the defaults for all projects created in the future?  I already have about a dozen projects -- just going into the old ones to make those changes will be tedious enough without having to do it on the new ones as well.   Thanks</description>
		<content:encoded><![CDATA[<p>Thanks for the quick response.  Now maybe you can tell me: is there a way to make those settings the defaults for all projects created in the future?  I already have about a dozen projects -- just going into the old ones to make those changes will be tedious enough without having to do it on the new ones as well.   Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: julian</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294488</link>
		<dc:creator>julian</dc:creator>
		<pubDate>Sun, 08 Nov 2009 13:12:09 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294488</guid>
		<description>so which one of these aren&#039;t contained in -Wmost?</description>
		<content:encoded><![CDATA[<p>so which one of these aren't contained in -Wmost?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://boredzo.org/blog/archives/2009-11-07/warnings/comment-page-1#comment-294448</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Sun, 08 Nov 2009 05:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://boredzo.org/blog/?p=1141#comment-294448</guid>
		<description>Yup. In Xcode 3.2, the build setting&#039;s human-readable name is simply “Undeclared Selectors”. Its under-the-hood name is &lt;code&gt;GCC_WARN_UNDECLARED_SELECTOR&lt;/code&gt;, in case you&#039;d like to turn it on now in advance of upgrading. (I doubt Xcode 3.1 will use it, but the setting won&#039;t hurt anything, either; Xcode 3.1 will just ignore it.)</description>
		<content:encoded><![CDATA[<p>Yup. In Xcode 3.2, the build setting's human-readable name is simply “Undeclared Selectors”. Its under-the-hood name is <code>GCC_WARN_UNDECLARED_SELECTOR</code>, in case you'd like to turn it on now in advance of upgrading. (I doubt Xcode 3.1 will use it, but the setting won't hurt anything, either; Xcode 3.1 will just ignore it.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.530 seconds -->
