Possible Duplicate:
Why no switch on pointers?
int main(int argc, char** argv)
{
void* not_a_pointer = 42;
switch(not_a_pointer)
{
case 42:
break;
}
return 0;
}
.
error: switch quantity not an integer
How can I portably use a switch-case for the value of a variable with a pointer type? The reason for this is that one of the callback functions in an API I'm using has a void* argument.
try casting to intptr_t, which is an integer type:
switch((intptr_t)not_a_pointer)
etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With