Hi there,
here I'm using Code Composer 5.4.0 (which includes compiler version 4.1.5) to create a programm for a MSP430F2132. My goal is to create an array of a variable size (I'm getting some data from the UART to process them).
As far as I read (http://processors.wiki.ti.com/index.php/TI_Compilers_and_Industry_Standards), TI's compiler is only C89 compliant, but variable length arrays were specified first in C99. However, your compiler has a switch to support GCC extensions (--gcc) which includes support for variable length array sizes, as seen in chapter 5.16.1 of document slau132h.pdf (MSP430 Optimizing C/C++ Compiler v 4.2, User's Guide).
But as far I can see, it still doesn't compile a statement like this:
void protokollparser(const unsigned char *const byte)
{
static unsigned char byteCounter;
if (byteCounter < HEADERSIZE)
{
currentPDU.packetheader.u8[byteCounter] = *byte;
byteCounter++;
return;
}
unsigned char data[currentPDU.packetheader.packetheader.length-1];
...
}
where currentPDU.packetheader.packetheader.length is different each time a packet is coming from the UART. If I try to compile this, I get this error:
#28 expression must have a constant value comm.c line 50 /MMU-Software/mup/lib_communication C/C++ Problem
So my question is: Why is this incorrect? What did I wrong?