I am doing the following in C
#define MAX_DATA_SIZE 500;
struct reliable_state {
char dataBuffer[MAX_DATA_SIZE];
}
i.e I want to use the #define constant as array size in structure declaration.
But above code gives weird error
.c:36: error: expected ‘]’ before ‘;’ token
So is there any other way to do this?
Yes you can, just remove ‘;’ in your define line:
With define you have compiler will actually ‘see’ your struct definition as
which is clearly erroneous.