I am thinking of using a global constant struct to manage configuration of some sub-systems. This means that I would like to use something like:
const struct SystemConfig {
.channels = 5,
.mode = NORMAL_MODE,
} SYSTEM_CONFIG;
And later use it in my code like usual:
...
numberOfChannels = SYSTEM_CONFIG.channels;
mode = SYSTEM_CONFIG.mode;
...
I would like to use this approach to skip #define
's.
My question is if the compiler will realize this and replace the values with their respective values when it is compiled, considering everything is constant?
EDIT: Sorry for tagging both C and C++, it's fixed now and my question relates only to C. The compiler I use is GCC with a ARM Cortex-M4 target.