Why is switch (ptr) illegal (or how to pointers differ from scalers)?
Joe Herman
dzoey at umd5.umd.edu
Fri Dec 16 10:00:45 AEST 1988
If I have a structure tag:
typdef struct foo {
int key;
int pitch;
} NOTE;
and I declare the following structures:
NOTE do, re, mi;
and the pointer:
NOTE *scale;
Why can I not do:
switch (scale) {
case &do:
do_something (scale);
break;
case &re:
do_somethingelse (scale);
break
}
etc.
The compiler I used says that scale isn't a scaler and that do, mi and re
are address expressions and can't be used in this context. As a test,
I casted scale to an int and it stopped complaining about scale, but still
complained about the case values even thought they evaluate to constant
values (I'm not sure this matters).
So, why is it important that scale be a scaler?
Joe Herman
dzoey at terminus.umd.edu
--
"Everything is wonderful until you know something about it."
More information about the Comp.lang.c
mailing list