Re: Declaration in "for"
Re: Declaration in "for"
- Subject: Re: Declaration in "for"
- From: Gordon Apple <email@hidden>
- Date: Fri, 23 Nov 2007 14:44:25 -0600
- Resent-date: Fri, 23 Nov 2007 15:02:25 -0600
- Resent-from: Gordon Apple <email@hidden>
- Resent-message-id: <C36C97C9.7B921%email@hidden>
- Resent-to: <email@hidden>
(Sorry about the title. I forget which list I'm on digest or full messages.
-- GA)
Which is the currently accepted standard? I vaguely remember something
mentioned about this at last year's WWDC. It turns out that the sample code
(in this case "Sketch") project is set for Xcode 2.4 and my project to Xcode
3.0. Is this a default difference?
It's not always a matter of just moving the declaration out of the "for"
loop because that changes the scope of the declaration sometimes requiring
renaming of variables.
I also stupidly checked the "Missing Braces and Parentheses" box and
then found a plethora of new warning messages about logic expressions
needing parentheses, when anyone with a modicum of understanding of operator
precedence can tell they are unnecessary. I quickly turned that one off.
> On Nov 22, 2007, at 11:43 PM, Gordon Apple wrote:
>
>> for (NSInteger index = 0;.....
>>
>> OK, what's the magic compiler/XCode setting to get rid of the
>> error
>> message on this? 10.5, no error in sample code, but my project's
>> compiler
>> complains about it not being C99 compliant. I understand the
>> problem -- I
>> just need to know what to set to so it doesn't complain every time
>> I purloin
>> code from sample code. I tried side-by-side project settings but
>> couldn't
>> figure out what was set different.
>>
>
>
> You need to change "C Language Dialect" to something like c99- the
> default seems to be ANSI C:
>
> int main()
> {
> for(int i=0;;);
> return 0;
> }
>
> ~ agentm$ gcc test.c
> test.c: In function 'main':
> test.c:3: error: 'for' loop initial declaration used outside C99 mode
> ~ agentm$ gcc -std=c99 test.c
> ~ agentm$
>
_______________________________________________
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