Re: gcc: error: case label does not reduce to an integer constant
Mark McIntyre wrote:[color=blue]
> On Tue, 28 Dec 2004 17:25:26 -0800, in comp.lang.c , Ben Pfaff
> <blp@cs.stanfor d.edu> wrote:
>[color=green]
>>Mark McIntyre <markmcintyre@s pamcop.net> writes:
>>[color=darkred]
>>>On Tue, 28 Dec 2004 22:05:39 +0000 (UTC), in comp.lang.c , Christopher
>>>Benson-Manica <ataru@nospam.c yberspace.org> wrote:
>>>
>>>>Ben Pfaff <blp@cs.stanfor d.edu> spoke thus:
>>>>
>>>>>A case label must be an integer constant.
>>>>
>>>>That's the same as saying that case labels must have integer values
>>>>computabl e at compile time, isn't it? (fmi)
>>>
>>>No, its not. They must be actual integer constants. Macros are ok, literals
>>>are ok, results of expressions are not.[/color]
>>
>>No, you're wrong.[/color]
>
> Possibly. But I disagree.[/color]
And you are wrong.
[color=blue][color=green]
>>Let me repeat the quote from the Standard that
>>I posted earlier:[/color]
>
> I saw it earlier. :-)[/color]
Then parse it again and try to get the semantics right this time ;-)
[color=blue][color=green]
>>An integer constant expression is not necessarily just a literal.[/color]
>
> I didn't say it had to be. I'd be interested in examples of suitable
> expressions you could use.[/color]
Everything that counts as a constant expression from
1
over
3<<2
to
(7+5)/6*4
Instead of the numbers, you of course can also use
symbolic and enumeration constants.
Cheers
Michael
--
E-Mail: Mine is a gmx dot de address.
Mark McIntyre wrote:[color=blue]
> On Tue, 28 Dec 2004 17:25:26 -0800, in comp.lang.c , Ben Pfaff
> <blp@cs.stanfor d.edu> wrote:
>[color=green]
>>Mark McIntyre <markmcintyre@s pamcop.net> writes:
>>[color=darkred]
>>>On Tue, 28 Dec 2004 22:05:39 +0000 (UTC), in comp.lang.c , Christopher
>>>Benson-Manica <ataru@nospam.c yberspace.org> wrote:
>>>
>>>>Ben Pfaff <blp@cs.stanfor d.edu> spoke thus:
>>>>
>>>>>A case label must be an integer constant.
>>>>
>>>>That's the same as saying that case labels must have integer values
>>>>computabl e at compile time, isn't it? (fmi)
>>>
>>>No, its not. They must be actual integer constants. Macros are ok, literals
>>>are ok, results of expressions are not.[/color]
>>
>>No, you're wrong.[/color]
>
> Possibly. But I disagree.[/color]
And you are wrong.
[color=blue][color=green]
>>Let me repeat the quote from the Standard that
>>I posted earlier:[/color]
>
> I saw it earlier. :-)[/color]
Then parse it again and try to get the semantics right this time ;-)
[color=blue][color=green]
>>An integer constant expression is not necessarily just a literal.[/color]
>
> I didn't say it had to be. I'd be interested in examples of suitable
> expressions you could use.[/color]
Everything that counts as a constant expression from
1
over
3<<2
to
(7+5)/6*4
Instead of the numbers, you of course can also use
symbolic and enumeration constants.
Cheers
Michael
--
E-Mail: Mine is a gmx dot de address.
Comment