• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: -Wall
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -Wall


  • Subject: Re: -Wall
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Thu, 5 Jun 2008 02:33:30 +0200


Le 5 juin 08 à 02:15, Stuart Malin a écrit :


On Jun 4, 2008, at 1:19 PM, 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 hope so :-)

I'm curious of the efficacy of doing so. For instance, even with - Wall, some of my lazy coding styles, e.g.:

	if (anInstance = [enumerator nextObject]) doSomethingWithAnInstance;

generated warnings and I was led to code such as:

if ((anInstance = [enumerator nextObject]) != nil) doSomethingWithAnInstance;

I guess this makes explicit my intent, and so can be argued this is better coding practice...

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.

So, I added -Wextra to -Wall (didn't yet turn on all the checkboxes), and one warning came up in oodles of places -- about methods that have unused parameters. This happens in many places for me, such as with Notifications (where I know what to do because of the fact of the notification, and don't need to access the notification object itself), or for IBActions that have a sender parameter but I don't need to access the sender object. So, to satisfy the compiler, I set these parameters to nil at the outset of the method, which I guess does make explicit to some future maintainer (including me) that the parameter is intentionally not used. This seems to me like adding superfluous code. Is there some other way I can inform the compiler (and a future maintainer) that the parameter is intentionally not used?

Yes, it is. You should not used unused argument as it prevent the compiler to optimize the function. All warning are not usefull and should not be used. It's meaningless to enabled all warning and try to fight the compiler to prevent them.


Some warning like unused param should be ignored (and so disabled).





I know these are minor issues, and perhaps ones of style, but I ask further because I read much in various places online about striving for no warnings, yet I don't find much info about coding practices that gets one there.




_______________________________________________
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: 
 >-Wall (From: Stuart Malin <email@hidden>)
 >Re: -Wall (From: "Sean McBride" <email@hidden>)
 >Re: -Wall (From: Stuart Malin <email@hidden>)

  • Prev by Date: Re: -Wall
  • Next by Date: Re: -Wall
  • Previous by thread: Re: -Wall
  • Next by thread: Re: -Wall
  • Index(es):
    • Date
    • Thread