• 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: strange compiler warnings - can't get rid of them?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strange compiler warnings - can't get rid of them?


  • Subject: Re: strange compiler warnings - can't get rid of them?
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 27 Nov 2007 18:39:30 +0100




The warning is correct (you asked for -Wconversion after all). The type of the expression (iconSize.width * 0.75) is double, and you are converting it to a float by passing it to NSMakeSize.

-Wconversion largely exists to catch problems when going from K&R C
(where it was quite tricky to pass a 'float' argument) to ANSI/ISO C ,
and as such doesn't have much use in other situations.

You can either turn off the warning or use this instead:
NSSize warningIconSize = {iconSize.width * 0.75, iconSize.height * 0.75};

You can also do NSSize iconSize = {iconSize.width * 0.75f, iconSize.height * 0.75f};
but it will be problematic with 64 bit compilation as NSSize on 64bits plateform uses double instead of float.


Maybe doing something like this will be ok for both cases:

NSSize iconSize = {iconSize.width * (CGFloat)0.75, iconSize.height * (CGFloat)0.75};

Jean-Daniel

_______________________________________________
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


  • Follow-Ups:
    • Re: strange compiler warnings - can't get rid of them?
      • From: "Sean McBride" <email@hidden>
    • Re: strange compiler warnings - can't get rid of them?
      • From: "Clark Cox" <email@hidden>
References: 
 >strange compiler warnings - can't get rid of them? (From: Jens Miltner <email@hidden>)
 >Re: strange compiler warnings - can't get rid of them? (From: "Clark Cox" <email@hidden>)

  • Prev by Date: Re: strange compiler warnings - can't get rid of them?
  • Next by Date: Re: strange compiler warnings - can't get rid of them?
  • Previous by thread: Re: strange compiler warnings - can't get rid of them?
  • Next by thread: Re: strange compiler warnings - can't get rid of them?
  • Index(es):
    • Date
    • Thread