Reputation: 263220
I was just browsing the C standard the other day, and the chapter about translation limits really had me stumped. Why are some translation limits 2^n, others 2^n+1 and others 2^n-k (for some small k)?
Here are just some examples:
15 nesting levels of compound statements, iteration control structures, and selection control structures
31 declarators nested by parentheses within a full declarator
32 expressions nested by parentheses within a full expression
31 significant initial characters in an internal identifier or a macro name
511 external identifiers in one translation unit
509 characters in a logical source line
257 case labels for a switch statement (excluding those for any nested switch statements)
Why isn't everything simply a power of two?
Upvotes: 4
Views: 196
Reputation: 86661
Why isn't everything simply a power of two?
To me, most of them look like 2n - 1, even the line length, once you add carriage return and line feed.
These are minimum limits, by the way. Compilers are allowed to exceed them.
Upvotes: 1