Hi,
When you declare a variable such as int length, does the identifier part (length) hold the actual address and when you assign say: length =5 then the identifier is deferenced? or is this incorrect what im assuming?
thank you
Hi,
When you declare a variable such as int length, does the identifier part (length) hold the actual address and when you assign say: length =5 then the identifier is deferenced? or is this incorrect what im assuming?
thank you
I am not a compiler expert, so someone will probably come along and correct me, but: The compiler can do it any way it wants to, as far as I understand the C standard.
When you do length = 5, the 5 has to be put somewhere in memory, that is true. I would expect that memory location to be found by the compiler via a look-up table, which may or may not fit your notion of "dereferenced".
I'd say tabstop is right. If the compiler can prove that in fact length is effectively a constant, it may even be able to simply remove the length variable and replace it with the constant value.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The compiler builds a symbol table which holds variable names. It looks up any uses of variables and builds the memory addresses right into the resultant code. In the finished code, unless symbolic information is kept for a run-time debugger, the variable names are not saved anywhere. If an executable consists of multiple C modules that share variables then symbol information is saved in the .obj's until the linker makes use of them to tie things together. In the end they are discarded also.
joe345 makes correct assumptions as to how one can think of how things work, conceptually. In keeping with C nomenclature of address, dereferencing, etc. How things work in practice in the interest of code speed, computer hardware utilization, things may be implemented differently.