Re: Case label does not reduce to an integer constant
Re: Case label does not reduce to an integer constant
- Subject: Re: Case label does not reduce to an integer constant
- From: Christiaan Hofman <email@hidden>
- Date: Wed, 10 Nov 2010 22:59:13 +0100
On Nov 10, 2010, at 21:54, Jonathon Kuo wrote:
> Xcode 3.2.4, Cocoa project, .m file.
>
> gcc sees kFlag as an integer in the flag_type assignment, but not when used as a case label?
>
> static const uint32_t kFlag = '3gI7';
> . . .
> uint32_t flag_type = kFlag;
> . . .
> switch (flag_type) {
> case kFlag:
> *** error: case label does not reduce to an integer constant
>
No. There is no requirement for initial value assignments. However values in a switch statement are required to be constant integer values (that's something very different from integer const variables). the way you usually handle this case is through an enum, sometimes a #define is used.
Christiaan
_______________________________________________
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