typedef struct { int len; char api_identifier; long DH; long DL; int source_addr_16bit; char options; char frame_id; char AT_com[2]; char status; int data_len=10; // stores the length of the data char data[20]; // also stores the "value" for at command response char checksum; } RxPacket; . . . . . . char buff[ RxPacket.data_len];
consider the above code written in c for ARM 7 in keil uvision4 I'd taken structure of few data, when i'm trying to access data_len by it's pointer through array then IDE shows error.....
main.c(402): error: #60: this operator is not allowed in an integral constant expression char buff[RxPacket.data_len];
any idea how do i solve this error
That code is not C. It might be C++.
C allows neither the intialization of struct elements in the middle of a struct type, nor the reference to struct elements by just naming the struct type.