7 years, 7 months ago.

MBED Online Compiler suddenly can't compile yesterdays successfull code anymore ...

I didn't change a single piece of my code but unfortunately from today on, the compiler displays the following error:

Error: Expression must have a constant value in "GPRSInterface/BufferedSerial/BufferedSerial.cpp", Line: 84, Col: 1 Error: This operator is not allowed in an integral constant expression in "GPRSInterface/BufferedSerial/BufferedSerial.cpp", Line: 84, Col: 1 Info: Unable to download. Fix the reported errors...

Any Idea what has changed since yesterday?

1 Answer

7 years, 7 months ago.

Looks like they've disabled Variable Length Arrays. So now, any time you declare an array in the middle of your code, you'll have to give it a size that is known at compile time. In fairness, apparently variable length arrays use the heap so they can cause hard to find bugs, especially on microlib since the heap isn't thread safe.

void myFunc(int num)
{
	char myArray1[10];					//Works
	char myArray2[sizeof(myArray1)];	//Works
	char myArray3[num];					//No longer works
}

Accepted Answer

Now it is working again (as before) ... strange ... looks like they returned to the old setup ...

posted by Rainer Geissendoerfer 16 Sep 2016