• 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: multi-character character constant and CFString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multi-character character constant and CFString


  • Subject: Re: multi-character character constant and CFString
  • From: Eric Albert <email@hidden>
  • Date: Tue, 26 Jul 2005 23:38:21 -0700

On Jul 26, 2005, at 10:58 PM, Chris Espinosa wrote:

On Jul 26, 2005, at 8:42 AM, Lawrence Gold wrote:

You can turn this warning off. In XCode, go to your target settings. In the search box type "four character literals". Make sure it's unchecked.

Another way to fix it, though it's kind of ugly, is to preface the code with \0: Change 'JP' to '\0\0JP'.\

Ugly and not endian-safe. When you build for Intel you'll get 0x0000 in your short.


Better to use

short foo = *(short *)("JP")

Actually, you'll get 0x4a50 ('JP') in your short on both Intel and PowerPC if you use '\0\0JP'. Multi-character constants are native-endian values, so you'll always get the same value on all platforms. The casting example above will result in 'JP' on PowerPC but 'PJ' on Intel, which probably isn't what you want.


-Eric

_______________________________________________
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: 
 >multi-character character constant and CFString (From: Julien Palmas <email@hidden>)
 >Re: multi-character character constant and CFString (From: Sailesh Agrawal <email@hidden>)
 >Re: multi-character character constant and CFString (From: Lawrence Gold <email@hidden>)
 >Re: multi-character character constant and CFString (From: Chris Espinosa <email@hidden>)

  • Prev by Date: Re: multi-character character constant and CFString
  • Next by Date: Re: Undefined symbols insanity after upgrading to Xcode 2.1...
  • Previous by thread: Re: multi-character character constant and CFString
  • Next by thread: Selecting alternative compiler via rules tab - compiler not listed
  • Index(es):
    • Date
    • Thread