CASE expr_no_commas ELLIPSIS expr_no_commas ':'
I saw such a rule in c's syntax rule,but when I try to reproduce it:
int test(float i)
{
switch(i)
{
case 1.3:
printf("hi");
}
}
It fails...
OK, this involves a bit of guesswork on my part, but it would appear that you're talking about a gcc
extension to C that allows one to specify ranges in switch
cases.
The following compiles for me:
int test(int i)
{
switch(i)
{
case 1 ... 3:
printf("hi");
}
}
Note the ...
and also note that you can't switch on a float
.
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