pYro_65:
No, its not required to be a compile time constant for arrays.void someFunc( int n ){
int arr[ n ];
Serial.println( sizeof( arr ) / sizeof( *arr ) );
}
//...
someFunc( random( 1, 30 ) );
But in that situation, the size is known at compile time - it is know to be: sizeof(int)*n - of course it is known, otherwise it wouldn't be able to do malloc() for the array. Clearly during execution it has to do that multiplication.
pYro_65:
typedef int arr_t[ 10 ];
And that one is definitely known at compile time as sizeof(arr_t) is a type. Doing that is no different from passing an array to a function defined as:
void someFunc (int array[10]);
In fact if you were to do this the size ceases to be known:
void someOtherFunc(int* arr){
sizeof(arr); //=sizeof(pointer)
}
arr_t array = {1,2,3,4,5,6,7,8,9,0};
someOtherFunc((int*)array_t);