[LCP]gcc: case label does not reduce to an integer constant
Angus Mackay
amackay at gusnet.cx
Fri Mar 22 12:33:05 UTC 2002
well, this is not leagle C for one. it isn't even leagle C++.
you can ONLY use integer constants in case labels in C, a "const int" IS NOT an
integer constant.
C++ added the ability to use a const int in a case label, but you have to let
the compiler what it's value is (ie. no extern).
try using a "#define" instead.
cheers, Angus.
ps. "type" is not a key word in either C or C++.
It would seem that Joachim Bauernberger (bj at gmx.net) said:
> Can sombody kindly tell me why the above error happens when compiling
> with gcc?
>
> The code looks as follows:
>
> typedef struct ctype_t
> {
> short type;
> .......
> } ctype_t;
>
> extern const short CT_TEXT;
> .....
> int foo(ctype_t *ct)
> {
>
> switch (ct->type) {
> case CT_TEXT:
> break;
> .........
> }
>
> Many thanks,
> Joachim
>
> --
> Disclaimer:
> By sending an email to ANY of my addresses you are agreeing that:
> 1) I am by definition, "the intended recipient"
> 2) All information in the email is mine to do with as I see fit and
> make such financial profit, political mileage, or good joke as it lends
> itself to. In particular, I may quote it on usenet.
> 3) I may take the contents as representing the views of your company.
> 4) This overrides any disclaimer or statement of confidentiality that
> may be included on your message.
>
>
> _______________________________________________
> This is the Linux C Programming List
> : http://lists.linux.org.au/listinfo/linuxcprogramming List
More information about the linuxCprogramming
mailing list