Simulater/Generated switch statement range in c
Is there a hack to support range case in a c(99?) or objective C switch statement ? I know this is not supported to write something like this: switch(x) case 1: case 2..10: case 11: But I was thinking there should be a way to generate code with a #define macro. Of course I can define a macro with the list of cases but I was hoping for a more elegant way like CASERANGE(x,x+10) which would generate: case x case x+1 case x+2 is it even possible ? GCC has an extension to the C language that allows something similar to your first example, but other than that, if there was a portable/ANSI way of