Hello, i'm new of this forum, i try to use the API of "bmx160.h" files with an 8-bit microcntroller in C- language but there is a declaretion of an array inside a function that needed dinamic allocation of memory.
In the file attached the array is named "uint8_t temp_buf[temp_len];" and the dimension of array "temp_len" is a parameter passed to the function.
The compiler give me this error: "BMX160_drivers/bmi160.c:1369:21: error: variable length arrays are not supported" .
Does anyone know what needs to be done to make the compiler allocate memory?
Solved! Go to Solution.
I was about to create thread with same error. in BMI085 API, i get two errors while compiling, by dynamicly alocating array in wrong way.
static int8_t get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bmi08x_dev *dev)
int8_t rslt = BMI08X_OK;
uint32_t temp_len = len + dev->dummy_byte;
uint8_t temp_buff[temp_len]; //Error[Pe028]:temp_len expression must have a constant value
Hello Kilohercas, thank you for your post.
I tried to identify the maximum number of registers that the array could contain: the registers of the BMX160 device are 126, for safety I added 16 bytes so I declared that vector as "static uint8_t temp_buf ;" this allows it to compile but i have yet to try if it works. Has anyone ever tried to do it this way?
I have discovered that can't use malloc () and free () on 8-bit microcontrollers family as describe in the page of compiler manual attached. Now i think to migrate an 32-bit Microchip microcontroller to obtain more memory space.