In the below example, I get an error on compilation
int main() {
int x = 10; // guess this is runtime initialisation
static int y = x; //guess this is loadtime initialisation
printf("x = %d, y = %d", x, y);
}
Error:
error: initializer element is not constant
My understanding is this is related to the way static and global members are initialised as against auto variables. I wanted to know the difference between the load time , runtime and compile-time initialisation I also wanted to know about the element's value getting stored in data section and stack and its effect on initialisation.