Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: XCode annoyance :-\
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XCode annoyance :-\



On Jan 23, 2004, at 5:01 PM, Martin Winter wrote:

Am 23.01.2004 um 16:56 schrieb Andrew Farmer:
On Fri, 23 Jan 2004 05:59:28 -0800, Martin Winter muttered:
you should enclose the statements after a "case:" in braces, like this:

switch (theType)
{
	case kLShapeLeft:
	{							// This is
	it!
	    array = {1, 1, 0, 0,
		     0, 1, 0, 0,
		     0, 1, 0, 0,
		     0, 0, 0, 0};
	    break;
	}							// This too!
	case kLShapeRight:
	{							// And here
....

Never seen that done before... it's not necessary.

Well, it apparently is! I do know that the standard C implementation does not require it. But I ran into the exact same problem before and this is how you fix it. Also, note the error messages:

ANSI C forces non-static variable initializers to be *before* any flow control logic (like if/case). Unless, of course, you partition your code using braces (as above), in which case the compiler treats the embraced code as a separate block explicitly.


If you change your array = {} to a for loop iterating across the array and setting its values one-by-one, you shouldn't need the braces within the case statement.

--
Mark Flider
_______________________________________________
studentdev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/studentdev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: studentdev digest, Vol 3 #809 - 8 msgs (From: Martin Winter <email@hidden>)
 >Re: studentdev digest, Vol 3 #809 - 8 msgs (From: email@hidden (Andrew Farmer))
 >Re: XCode annoyance :-\ (From: Martin Winter <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.