Hi all,
what would be the best way to init a huge array, which will never change his values? Will the array affect the stack if I use const aray[][] or should I use static const array[][]?
What would be the best way if the array is not const during the whole program?
best regards Hans
Will the array affect the stack if I use const aray[][] or should I use static const array[][]?
It is possible that the array ends up on the stack if static is not used.
As long as the array does not need to be in RAM (e.g. to increase speed or power consumption), such an array could be "initialized" at FW load time (i.e. it's simply put in the EEPROM somewhere and accessed there).
That very much depends on your definition of "best", and to some degree on the contents of the array.
It is possible that the array ends up on the stack if static is not used
Is it also recommended to declare all functions with static if they are only used in one file? Or is there no disadavantage if I don't use static?
static testfunction(void) {};
Static for a function is just a question of name-space pollution.
Try to strive for encapsulation, not letting all of the program know about the internals of your modules. That will stop you from getting tempted to use these functions where they shouldn't. Encapsulation will make it easier to rewrite a module to use another algorithm without breaking the rest of the program.
View all questions in Keil forum