Re: -Wall
Re: -Wall
- Subject: Re: -Wall
- From: Tommy Nordgren <email@hidden>
- Date: Thu, 5 Jun 2008 15:42:04 +0200
On 5 jun 2008, at 13.44, Army Research Lab wrote:
On Wed, 4 Jun 2008 19:19:55 -0400, Sean McBride wrote:
>On 6/4/08 10:20 AM, Stuart Malin said:
>
>>I have decided to write my application "cleanly" -- that is, to not
>>have any compiler warnings.
>
>Great!
I second that, its a GOOD thing when people turn on the warnings and
fix the bugs!
>>What then is the effect on the
>>Warnings settings of the Build (ignored? do I need to set these
>>checkboxes as well for the various warnings?) Should I be setting -
>>Wall as an "Other Warning Flags" of the Warnings Build Settings, or
>>am I doing this properly by setting as a compiler flag?
>
>You'll need to consult the gcc man page I'm afraid.... But -Wall does
>not enable _all_ warnings. Some of the warning checkboxes Xcode
>provides are redundant (but harmless) if -Wall is on. OTOH, some of
>them add to what -Wall provides. I suggest checking as many as you
can
>and add -Wextra (instead of -Wall). If you want more, you need to
scour
>the gcc man page.
IIRC, -Wextra is not a superset of -Wall; you have to have both for
to cover it all. I suggest adding the following line in the warning
flags under the 'All configurations' option in 'Configuration':
-Wall -Wextra -pedantic
If you are compiling Objective-C, you'll probably want to add the
following:
-Wno-import
This turns off warnings for import statements.
In the 'Debug' configuration, check and see what your 'Optimization
Level' is; if you set it to '-O0', then when you use the debugger,
it will be easier to step through, but you will get many, many
warnings about how the compiler can't check for uninitialized
variables unless the optimization level is higher. To fix this, set
the warning flags line IN THE DEBUG CONFIGURATION to the following:
-Wall -Wextra -pedantic -Wno-import -Wno-uninitialized
It is possible to import the settings from a lower layer here.
$(VALUE) -Wno-unitialized
The reason you have to repeat the line is because your settings in
the debug configuration will override your higher level settings.
Also, to turn off the warnings about unused parameters, add '-Wno-
unused' to your warnings line.
All of these warnings can be found at:
http://gcc.gnu.org/onlinedocs/
For GCC 4.0.4, go to:
http://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Warning-Options.html#Warning-Options
Finally, some versions of Xcode have a bug where you can't turn
ZeroLink off; that means you'll get what looks like a clean compile,
but you'll crash as soon as you try to run. The only way to fix
this is to hand edit the project file to turn off ZeroLink.
1) Find your project file. It ends in '.xcodeproj'. This is a
bundle, so you can either use the terminal and cd into it, or you
can control click on it to open it up (control click -> 'Show
Package Contents').
2) Look for 'project.pbxproj'
3) Open this in a text editor OTHER THAN Xcode.
4) Look for any line with 'ZERO_LINK' on it. Change any that say
'YES' to 'NO'. Save the file.
At this point, the next time you open up your project ZeroLink will
be off.
If you REALLY want to get pedantic about your warnings, set your 'C
Language Dialect' to 'C99', turn off 'Allow 'asm', 'inline',
'typeof'', 'Recognize Pascal Strings', 'CodeWarrior-Style Inline
Assembly', and then clean and rebuild; that'll make your code as
clean and portable as possible.
Good luck,
Cem Karan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >Re: -Wall (From: Army Research Lab <email@hidden>) |