• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Mysterious Parse Error in switch statement
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Mysterious Parse Error in switch statement


  • Subject: RE: Mysterious Parse Error in switch statement
  • From: email@hidden
  • Date: Thu, 18 Dec 2003 12:39:48 -0000

Hi Sven,

Is it because Obj-C is more like C than C++ and it doesn't like variables
declared any where you like but needs them at the beginning of a code block.

Try enclosing your case block in curly braces:

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:
}

Alun Carp
Driver Development Team Leader
Data Encryption Systems Limited

-----Original Message-----
From: Sven Hoffmann [mailto:email@hidden]
Sent: 18 December 2003 11:55
To: email@hidden
Subject: Mysterious Parse Error in switch statement


Hi,

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??

thanks,

sven
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Mysterious Parse Error in switch statement
      • From: j o a r <email@hidden>
  • Prev by Date: Re: Mysterious Parse Error in switch statement
  • Next by Date: Re: Mysterious Parse Error in switch statement
  • Previous by thread: Re: Mysterious Parse Error in switch statement
  • Next by thread: Re: Mysterious Parse Error in switch statement
  • Index(es):
    • Date
    • Thread