Expanding on R's answer a little bit: fieldWidth
is not a constant expression; it's a const
-qualified variable. Its value is not established until run-time, so it cannot be used where a compile-time constant expression is required (such as in an array declaration, or a case label in a switch
statement, etc.).
Compare with the macro FIELD_WIDTH
, which after preprocessing expands to the constant expression 10
; this value is known at compile time, so it can be used for array dimensions, case labels, etc.