Storage size of ‘data’ isn’t constant

#include <stdio.h>

#define MS_PER_SAMPLE	5
#define MS25	((int) ( 25/MS_PER_SAMPLE + 0.5 ))
#define LPBUFFER_LGTH ((int) (2*MS25))

int main(){

   static int data[LPBUFFER_LGTH];


when I use gcc compile the code above,I receive that:

zhengyangtongxie:~/workspace $ gcc -o test test.c
test.c: In function ‘main’:
test.c:12:15: error: storage size of ‘data’ isn’t constant
static int data[LPBUFFER_LGTH];

I find that if I change MS25 from ((int) ( 25/MS_PER_SAMPLE + 0.5 )) to ((int) ( 25/MS_PER_SAMPLE + 5 ))。No error report. Why can’t the int change the type from double to int ? How can I resolve this problem ? Thank you very much !


I think this is the normal behavior of gcc, some simple math is optimized during compilation but not all, so static int data[((int) ( 1 + 1))]; works, but static int data[((int) ( 1 + 1.0))]; doesn’t.
Try asking this on forums related to c, this is for questions related cloud9.
If you are from cs50, try asking on cs50 reddit or facebook groups