Can sizeof() be used to define an array length?

The sizeof expression is evaluated at compile time (by the compiler not the preprocessor) so the expression is legal.

There's an exception to this rule in C99 where dynamic arrays are allowed. In that case sizeof is, depending on context, evaluated at runtime (http://en.wikipedia.org/wiki/Sizeof). It doesn't change the legality of the expression in the question.


Yes, it can and it will not even be a dynamically sized, because sizeof(double) is a compile-time constant.