Hey everyone,
I've been diving deeper into the world of C programming, and I came across a topic that I'm hoping you can help me clarify. I want to understand when memory locations for variables are actually assigned in C - is it at runtime, compile time, or link time?
I've read a bit about it, but I'm still a little confused, and I'm sure some of you more experienced programmers can shed some light on this. From what I gathered:
Could someone clarify these points for me?
Looking forward to learning from you all!
Thanks! @WBahn
I've been diving deeper into the world of C programming, and I came across a topic that I'm hoping you can help me clarify. I want to understand when memory locations for variables are actually assigned in C - is it at runtime, compile time, or link time?
I've read a bit about it, but I'm still a little confused, and I'm sure some of you more experienced programmers can shed some light on this. From what I gathered:
- Compile Time: During the compilation process, the C compiler translates the high-level C code into assembly language. However, I'm not sure if memory locations for variables are assigned at this stage or not.
- Link Time: After compilation, during the linking phase, object files are combined to create an executable or a shared library. Again, I'm not entirely sure if memory allocation happens here.
- Runtime: This is the phase where the program is actually executed. I've heard that memory locations for variables are assigned during runtime. But how exactly does this work? Does the compiler have any role in this process?
Could someone clarify these points for me?
Looking forward to learning from you all!
Thanks! @WBahn
Last edited:
