Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 3 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
8 years, 3 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 }