In C the sizeof()
operator cannot be resolved in preprocessor conditions. If other operators such as +
or -
can be (so long as the operands are constants) then what is different about sizeof()
?
What technical limitations prevent sizeof()
from being resolved at preprocess time while other operators can be and what would it take for C to permit constructs such as the following?
#if sizeof(int) == 4// Code#endif
sizeof()
is compile time constant but not preprocess time constant, hence the following is valid:
static char array[sizeof(int)];
If the compiler knows type sizes why can the preprocessor not?