Re: How to fix warning?

2013-08-29 Thread Dave

On 29 Aug 2013, at 03:05, Stephen J. Butler stephen.but...@gmail.com wrote:

 Are those really always constant? Why not:
 
 NSCharacterSet *stopCharacters = [NSCharacterSet 
 characterSetWithCharactersInString:@ \t\n\r\x85\x0C\u2028\u2029];

I've no idea what it is trying to do, it's in a third party library of a 
project I inherited and I just want to stop the warnings!

Cheers
Dave



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to fix warning?

2013-08-29 Thread Uli Kusterer
On Aug 28, 2013, at 10:26 PM, Dave d...@looktowindward.com wrote:
 NSCharacterSet *stopCharacters = [NSCharacterSet 
 characterSetWithCharactersInString:[NSString stringWithFormat:@ 
 \t\n\r%C%C%C%C, 0x0085, 0x000C, 0x2028, 0x2029]];

Well, the %C expects a unichar (which is defined as another name for an 
unsigned short), while you are giving it 0x0085, which is a (signed) int. While 
you can mark a literal as an unsigned int by writing e.g. 0x0085U, there's no 
way to write a 'short' literal in C. So the best you can do is write the 
numbers as 

NSCharacterSet *stopCharacters = [NSCharacterSet 
characterSetWithCharactersInString:[NSString stringWithFormat:@ 
\t\n\r%C%C%C%C, (unichar)0x0085U, (unichar)0x000CU, (unichar)0x2028U, 
(unichar)0x2029U]];

I.e. make them unsigned and typecast them to short. Using escape sequences 
instead as others have suggested is probably the better solution (then you can 
get rid of the entire -stringWithFormat: call as well and just write the whole 
string as one literal). This'll work as long as you are using a current version 
of the llvm compiler, I think. Older versions of the compilers included in 
Xcode didn't support the Unicode escape sequence as far as I remember.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://www.zathras.de


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to fix warning?

2013-08-28 Thread Dave
Hi,

I am getting the following warning 

warning: format specifies type 'unsigned short' but the argument has type 'int' 
[-Wformat]

on this statement:

NSCharacterSet *stopCharacters = [NSCharacterSet 
characterSetWithCharactersInString:[NSString stringWithFormat:@ 
\t\n\r%C%C%C%C, 0x0085, 0x000C, 0x2028, 0x2029]];

What is the best way to fix this?

Thanks a lot
Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to fix warning?

2013-08-28 Thread Tom Davie

On 28 Aug 2013, at 22:26, Dave d...@looktowindward.com wrote:

 Hi,
 
 I am getting the following warning 
 
 warning: format specifies type 'unsigned short' but the argument has type 
 'int' [-Wformat]
 
 on this statement:
 
 NSCharacterSet *stopCharacters = [NSCharacterSet 
 characterSetWithCharactersInString:[NSString stringWithFormat:@ 
 \t\n\r%C%C%C%C, 0x0085, 0x000C, 0x2028, 0x2029]];
 
 What is the best way to fix this?

The type of integer literals in C is “int” by default.  If you want them to be 
shorts (or unsigned, as is the bigger issue in this case), you must cast them 
either explicitly (by adding the casts in this expression), or implicitly, by 
assigning the littorals to a variable of the desired type.

Tom Davie


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to fix warning?

2013-08-28 Thread Boyd Collier
I think I understand what the problem is and the fix, but what does the  
following the opening quote signify?

Boyd


On Aug 28, 2013, at 1:30 PM, Tom Davie tom.da...@gmail.com wrote:

 
 On 28 Aug 2013, at 22:26, Dave d...@looktowindward.com wrote:
 
 Hi,
 
 I am getting the following warning 
 
 warning: format specifies type 'unsigned short' but the argument has type 
 'int' [-Wformat]
 
 on this statement:
 
 NSCharacterSet *stopCharacters = [NSCharacterSet 
 characterSetWithCharactersInString:[NSString stringWithFormat:@ 
 \t\n\r%C%C%C%C, 0x0085, 0x000C, 0x2028, 0x2029]];
 
 What is the best way to fix this?
 
 The type of integer literals in C is “int” by default.  If you want them to 
 be shorts (or unsigned, as is the bigger issue in this case), you must cast 
 them either explicitly (by adding the casts in this expression), or 
 implicitly, by assigning the littorals to a variable of the desired type.
 
 Tom Davie
 
 
 ___
 
 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
 
 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com
 
 Help/Unsubscribe/Update your Subscription:
 https://lists.apple.com/mailman/options/cocoa-dev/bcollier%40mail.sdsu.edu
 
 This email sent to bcoll...@mail.sdsu.edu


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to fix warning?

2013-08-28 Thread Jens Alfke

On Aug 28, 2013, at 4:51 PM, Boyd Collier bcoll...@mail.sdsu.edu wrote:

 I think I understand what the problem is and the fix, but what does the  
 following the opening quote signify?

It’s just a literal ““ character in the string; nothing magic. (The code looks 
like it’s constructing an NSCharacterSet, and ““ must be one of the characters 
that should go in the set.)

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to fix warning?

2013-08-28 Thread Stephen J. Butler
Are those really always constant? Why not:

NSCharacterSet *stopCharacters = [NSCharacterSet
characterSetWithCharactersInString:@ \t\n\r\x85\x0C\u2028\u2029];


On Wed, Aug 28, 2013 at 3:26 PM, Dave d...@looktowindward.com wrote:

 Hi,

 I am getting the following warning

 warning: format specifies type 'unsigned short' but the argument has type
 'int' [-Wformat]

 on this statement:

 NSCharacterSet *stopCharacters = [NSCharacterSet
 characterSetWithCharactersInString:[NSString stringWithFormat:@
 \t\n\r%C%C%C%C, 0x0085, 0x000C, 0x2028, 0x2029]];

 What is the best way to fix this?

 Thanks a lot
 Dave


 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 Please do not post admin requests or moderator comments to the list.
 Contact the moderators at cocoa-dev-admins(at)lists.apple.com

 Help/Unsubscribe/Update your Subscription:

 https://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com

 This email sent to stephen.but...@gmail.com
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com