Recast a const int16_t[] array to a int16_t[] array, why can't I re-write the element in the recasted array?
Hi, community,
I am converting a TI CCS project into STM32 project.
In the TI CCS project, a const array is defined in the file array.c, e.g.
const uint16_t ARRAY[] = {0, 1, 2, 3, 4, 5};
and in the main.c, the array is recast as
extern uint16_t ARRAY[];
and the user can update the array elements without any error, e.g.
ARRAY[1] = 3;
When I put the files into STM32CubeIDE, the compiler didn't complain about the recast and assignment, but
ARRAY[1] = 3;
didn't execute correctly. When I trace the variable value in debug mode, the ARRAY[1] = 1.
Thanks for reading my post and I look forward to your suggestions and solutions to my question.
