C const - , , . , ++. .
gcc builtin (int __builtin_constant_p (exp)), , .
, - undefined, -. [1]
Because constant expressions are evaluated at compile time, they provide a safe processing time and often use code space and possibly data space. In addition, in some places (for example, global initializers), only constant expressions are allowed. See Standard.
[1]: One example is the right shift of a sign constant with a constant sign, for example. -1 >> 24. Since this implementation is defined, the compiler may give a different result from running the program using a variable that has the same value:
int i = -1;
(-1 >> 24) == (i >> 24)
^ ^--- run-time evaluated by target
+--- compile-time evaluated by compiler
Comparison may fail.
source
share