6
我在這個代碼塊得到一個編譯錯誤:預計表達之前......在switch語句
switch(event) {
case kCFStreamEventHasBytesAvailable:
UInt8 buf[BUFSIZE];
CFIndex bytesRead = CFReadStreamRead(stream, buf, BUFSIZE);
if (bytesRead > 0) {
handleBytes(buf, bytesRead);
}
break;
case kCFStreamEventErrorOccurred:
NSLog(@"A Read Stream Error Has Occurred!");
case kCFStreamEventEndEncountered:
NSLog(@"A Read Stream Event End!");
default:
break;
}
線UInt8 buf[BUFSIZE];
導致編譯器抱怨「UINT8之前預期的表達」爲什麼?
謝謝!
它描述這裏](http://stackoverflow.com/questions/92396/ why-cant-variables-be-decla-in-a-switch-statement)。 – 2011-03-02 05:19:30
這已被問了很多很多次:http://stackoverflow.com/questions/92396/why-cant-variables-be-declared-in-a-switch-statement http://stackoverflow.com/questions/ 1231198/declaring-variables-inside-a-switch-statement http://stackoverflow.com/questions/1115304/can-i-declare-variables-inside-an-objective-c-switch-statement http:// stackoverflow。 com/questions/1180550 /奇怪開關錯誤在obj-c http://stackoverflow.com/questions/3757445/switch-case-declaration-with-initialization-declaration-and-then-assignment – 2011-03-02 06:21:54