This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Does Keil MDK 5 supports Variable-length array (VLA)?

Hi, I use Keil MDK 5.21 to develop Cortex-M processors.

Suppose I have a function foo.

void foo(uint8_t count){
uint16_t array[count]; // ... }

This can be compiled. However, the code cannot run on my Cortex-M MCU.

If I try to debug, it cannot reach the main function.

If I comment that variable,

//uint16_t array[count];

then the code runs.

Does Keil MDK's compiler support VLA?

Are there extra settings to be done to use it?

-Best Regards

Parents
  • HI, Per Westermark.

    I didn't know about the heap allocation. Didn't expected it.

    I'm using nRF52832-QFAA (Cortex-M4F MCU).

    Most of the Nordic's example projects configure the heap with the following preprocessor.

    __HEAP_SIZE=0 (In the Options for Target -> C/C++ -> Preprocessor Symbol)

    So I think there was no heap memory and that caused the previous problem.

    By the way, I'm not familiar with Keil MDK; I used IAR EWARM 7 more often.

    I'm trying to get use to Keil MDK.

    How can I configure the heap size? Do I have to change the IRAM section to do it? Or does that preprocessor does all the job?

    -Best Regards

Reply
  • HI, Per Westermark.

    I didn't know about the heap allocation. Didn't expected it.

    I'm using nRF52832-QFAA (Cortex-M4F MCU).

    Most of the Nordic's example projects configure the heap with the following preprocessor.

    __HEAP_SIZE=0 (In the Options for Target -> C/C++ -> Preprocessor Symbol)

    So I think there was no heap memory and that caused the previous problem.

    By the way, I'm not familiar with Keil MDK; I used IAR EWARM 7 more often.

    I'm trying to get use to Keil MDK.

    How can I configure the heap size? Do I have to change the IRAM section to do it? Or does that preprocessor does all the job?

    -Best Regards

Children
No data