Re: Mysterious Parse Error in switch statement
Re: Mysterious Parse Error in switch statement
- Subject: Re: Mysterious Parse Error in switch statement
- From: j o a r <email@hidden>
- Date: Thu, 18 Dec 2003 13:36:16 +0100
If you declare local variables in switches, you need to add a new
block, using curly braces:
case 'k' :
{
float y;
// other stuff
}
case 'v' :
// etc.
j o a r
On 2003-12-18, at 12.54, Sven Hoffmann wrote:
>
I wrote this pretty usual switch stetement:
>
>
>
const unichar constOperatorChar = [operator characterAtIndex:0];
>
>
switch(constOperatorChar){
>
case 'k':
>
float cmyk[4];
>
for (i = 0; i < 4; i++){
>
cmyk[i] = [[words objectAtIndex:i]floatValue];
>
}
>
[NSColor colorWithDeviceCyan:cmyk[0] magenta:cmyk[1]
>
yellow:cmyk[2] black:cmyk[3] alpha:1];
>
case 'v':
>
case 'V':
>
default:
>
}
>
>
>
>
i keep getting a parse error before "float"
>
that is in right after the first case label 'k'.
>
>
without any code after the labels it compiles fine and the statement
>
itself seems okay.
>
adding any code after the label makes it complain.
>
>
does anybody have a clue what could be wrong here??
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.