what data structure does the c runtime use to store information about variable like type, size etc
ex:
void foo(){
int bar=0, goo=44;
int*q, *p = &goo;
//some code follows
bar = goo + bar*9;
...
q=p;
...
}
In the above code we have local variable bar and goo which will be allocated on stack when control reaches the foo function. But how will runtime determine at later point, when these variables are referenced, that these variables are of so and so type and of so and so size ?
The runtime does not keep any such information – it is compiled into the binary code the compiler generates as constants. The compiler knows the size of each type, so it knows how to generate proper machine code for cleaning up the stack, accessing array elements, accessing fields of the struct, et cetera. There is no need to keep this information around at runtime, because the binary code already contains all the appropriate instructions.