Re: NSUInteger in for-loop?

2008-09-15 Thread Quincey Morris
On Sep 15, 2008, at 11:24, Sean McBride wrote: '#pragma unused' will cause some compilers to warn "unknown pragma". Though, since this is the Cocoa list, and Cocoa is not really portable, I guess it doesn't matter. There's also the convenient macro "__unused", which seems to work fine for

Re: NSUInteger in for-loop?

2008-09-15 Thread Sean McBride
On 9/15/08 12:17 PM, Nathan Kinsinger said: >> Well, to each his own. I find it is a worthwhile tradeoff. For >> action >> methods, just do: >> >> - (IBAction)handleButton:(id)sender >> { >>(void)sender; >> >>... >> } > >There is also "#pragma unused", it's kind of ugly but is specific >

Re: NSUInteger in for-loop?

2008-09-15 Thread Charles Srstka
On Sep 15, 2008, at 12:57 PM, Michael Ash wrote: gcc allows you to disable individual warnings. So using "-Wall -Wextra -Wno-unused-parameter" will give you all of the good warnings with none of the annoying unused parameter ones. In practice, this single warning is the only one I've found in th

Re: NSUInteger in for-loop?

2008-09-15 Thread Nathan Kinsinger
On Sep 15, 2008, at 11:54 AM, Sean McBride wrote: On 9/15/08 12:48 PM, Charles Srstka said: -Wall yes, but -Wextra can get pretty obnoxious. In my experience, that one tends to flood you with "unused parameter" warnings every time you have an IBAction that doesn't use the "sender" parameter, o

Re: NSUInteger in for-loop?

2008-09-15 Thread Michael Ash
On Mon, Sep 15, 2008 at 1:48 PM, Charles Srstka <[EMAIL PROTECTED]> wrote: > On Sep 15, 2008, at 11:34 AM, Sean McBride wrote: > >> And gcc can catch these kinds of things! >> >> $ gcc-4.2 -framework Cocoa -std=c99 -Wall -Wextra ~/Desktop/test.m >> >> /Users/sean/Desktop/test.m: In function 'main':

Re: NSUInteger in for-loop?

2008-09-15 Thread Sean McBride
On 9/15/08 12:48 PM, Charles Srstka said: >-Wall yes, but -Wextra can get pretty obnoxious. In my experience, >that one tends to flood you with "unused parameter" warnings every >time you have an IBAction that doesn't use the "sender" parameter, or >you have a notification handler that doesn't use

Re: NSUInteger in for-loop?

2008-09-15 Thread Charles Srstka
On Sep 15, 2008, at 11:34 AM, Sean McBride wrote: And gcc can catch these kinds of things! $ gcc-4.2 -framework Cocoa -std=c99 -Wall -Wextra ~/Desktop/test.m /Users/sean/Desktop/test.m: In function 'main': /Users/sean/Desktop/test.m:7: warning: comparison of unsigned expression = 0 is alway

Re: NSUInteger in for-loop?

2008-09-15 Thread Sean McBride
On 9/15/08 2:45 PM, Brett Powley said: >Second problem (which you'll see if you change the NSLog): counter is >unsigned, so it *never* "turns negative". And gcc can catch these kinds of things! $ gcc-4.2 -framework Cocoa -std=c99 -Wall -Wextra ~/Desktop/test.m /Users/sean/Desktop/test.m: In fu

NSUInteger in for-loop?

2008-09-14 Thread Alex Reynolds
Thanks all for your quick insight! -Alex ___ 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

Re: NSUInteger in for-loop?

2008-09-14 Thread Graff
On Sep 14, 2008, at 9:15 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote: I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for" loop within these bounds, the l

Re: NSUInteger in for-loop?

2008-09-14 Thread Jason Coco
On Sep 15, 2008, at 00:45 , Brett Powley wrote: On 15/09/2008, at 2:15 PM, Alex Reynolds wrote: I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for"

Re: NSUInteger in for-loop?

2008-09-14 Thread Jason Coco
On Sep 15, 2008, at 00:44 , Alex Reynolds wrote: The %lu with casting seems to run into the same issue as %u: ... 2008-09-14 21:43:07.241 NSUIntTest[19779:10b] NSUInteger: 2 2008-09-14 21:43:07.259 NSUIntTest[19779:10b] NSUInteger: 1 2008-09-14 21:43:07.260 NSUIntTest[19779:10b] NSUInteger: 0

Re: NSUInteger in for-loop?

2008-09-14 Thread Clark Cox
On Sun, Sep 14, 2008 at 9:44 PM, Alex Reynolds <[EMAIL PROTECTED]> wrote: > The %lu with casting seems to run into the same issue as %u: > > ... > 2008-09-14 21:43:07.241 NSUIntTest[19779:10b] NSUInteger: 2 > 2008-09-14 21:43:07.259 NSUIntTest[19779:10b] NSUInteger: 1 > 2008-09-14 21:43:07.260 NSUI

Re: NSUInteger in for-loop?

2008-09-14 Thread Jason Coco
On Sep 15, 2008, at 00:42 , Alex Reynolds wrote: Interesting: ... 2008-09-14 21:38:56.311 NSUIntTest[19750:10b] NSUInteger: 2 2008-09-14 21:38:56.329 NSUIntTest[19750:10b] NSUInteger: 1 2008-09-14 21:38:56.341 NSUIntTest[19750:10b] NSUInteger: 0 2008-09-14 21:38:56.344 NSUIntTest[19750:10b] NS

Re: NSUInteger in for-loop?

2008-09-14 Thread Brett Powley
On 15/09/2008, at 2:15 PM, Alex Reynolds wrote: I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for" loop within these bounds, the loop does not seem

Re: NSUInteger in for-loop?

2008-09-14 Thread Alex Reynolds
The %lu with casting seems to run into the same issue as %u: ... 2008-09-14 21:43:07.241 NSUIntTest[19779:10b] NSUInteger: 2 2008-09-14 21:43:07.259 NSUIntTest[19779:10b] NSUInteger: 1 2008-09-14 21:43:07.260 NSUIntTest[19779:10b] NSUInteger: 0 2008-09-14 21:43:07.261 NSUIntTest[19779:10b] NSUInt

Re: NSUInteger in for-loop?

2008-09-14 Thread Alex Reynolds
Interesting: ... 2008-09-14 21:38:56.311 NSUIntTest[19750:10b] NSUInteger: 2 2008-09-14 21:38:56.329 NSUIntTest[19750:10b] NSUInteger: 1 2008-09-14 21:38:56.341 NSUIntTest[19750:10b] NSUInteger: 0 2008-09-14 21:38:56.344 NSUIntTest[19750:10b] NSUInteger: 4294967295 2008-09-14 21:38:56.344 NSUIntT

Re: NSUInteger in for-loop?

2008-09-14 Thread j o a r
On Sep 14, 2008, at 9:15 PM, Alex Reynolds wrote: I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for" loop within these bounds, the loop does not se

Re: NSUInteger in for-loop?

2008-09-14 Thread Jerry Krinock
On 2008 Sep, 14, at 21:31, Nathan Kinsinger wrote: On Sep 14, 2008, at 10:15 PM, Alex Reynolds wrote: NSLog(@"NSUInteger: %d", counter); The correct type modifier for unsigned integers is %u not %d. Switch it and try again to see what's really happening. Ah, I believe he'll pro

Re: NSUInteger in for-loop?

2008-09-14 Thread Nathan Kinsinger
On Sep 14, 2008, at 10:15 PM, Alex Reynolds wrote: NSLog(@"NSUInteger: %d", counter); The correct type modifier for unsigned integers is %u not %d. Switch it and try again to see what's really happening. --Nathan ___ Cocoa-dev mailing l

NSUInteger in for-loop?

2008-09-14 Thread Alex Reynolds
I'm wondering if I'm using unsigned integers (specifically NSUInteger) properly or not. I was under the impression that unsigned integers run from 0 to MAX_INT, but when I use them in a "for" loop within these bounds, the loop does not seem to always obey these constraints. For example: