Why do C have these strange translation limits (section 2.2.4.1)?

I was just looking at standard C the other day, and the chapter on transfer limits really puzzled me. Why are there some transfer limits 2 ^ n, others 2 ^ n + 1 and others 2 ^ nk (for some small k)?

Here are some examples:

  • 15 levels of nesting of compound operators, iteration control structure and choice control structure.

  • 31 declarators enclosed in parentheses in a full declarator

  • 32 expressions enclosed in parentheses in full expression

  • 31 significant leading characters in the internal identifier or macro name

  • 511 external identifiers in one translation unit

  • 509 characters in the logical line of the source

  • 257 case labels for the switch statement (excluding those nested switch statements)

Why is not all just the power of two?

+4
source share
1 answer

Why is not all just the power of two?

For me, most of them look like 2 n - 1, even the length of the line, after adding a carriage return and line feed.

These are the minimum limits, by the way. Compilers are allowed to exceed them.

+1
source

Source: https://habr.com/ru/post/1610419/


All Articles