Re: 8051 and a C switch statement



robertwessel2@xxxxxxxxx wrote:
On Dec 28, 4:39 pm, Martin Griffith <mart_in_medina@xxxxxxxx> wrote:
" how big can I make the switch statement?"
Whats the limit?
I'm using the rasionance C compiler.

The C standard (C89/90) requires that the implementation support at
least 257 labels in a switch statement.

These limits aren't worth anything. A compiler is required to compile at
least one program containing 257 case labels. This one and only program
might look like this:
int main() {
switch (0) {
case 1: case 2: ...... case 257: default: break;
}
return 0;
}
and the compiler is still conformant. Some others (like an object size
of 32767) cannot be fulfilled at all by some architectures.


Stefan

.



Relevant Pages

  • Re: Just curiosity about some constructs
    ... and sometimes people wanted to give the compiler hints ... This is about the switch statement. ... A whilewill execute the statement after the ... with labels and goto (although case labels are a little different ...
    (comp.lang.c)
  • Re: DPROD issues
    ... a switch like that typically ... makes a compiler nonstandard in that mode. ... treatment of specific intrinsics is one ... subroutine sub1a ...
    (comp.lang.fortran)
  • Re: Banks and economy
    ... so I switched to working on a C compiler. ... I've found I keep using C99 features or limits, e.g., quantity of switch ... if you massively exceed the minimum required number of labels in a switch ...
    (alt.lang.asm)
  • Re: [OT] Funny
    ... >> the NAG compiler does have a switch to allow you to tell it ... or the compiler simply isn't conforming. ... more arithmetic in computing addresses of array elements -- dis- ...
    (comp.lang.fortran)
  • Re: inline power function replacement
    ... switch ) ... and the order of the cases should not matter if the compiler ... the absolutely least overhead for the vast majority of cases. ... roughly the same overhead as an indirect function call (calling through ...
    (comp.lang.c)