How are variable names / addresses represented at bit level?

It might be a dumb question, but I'm pretty new to programming, so bear with me.

Say, for the sake of argument, I'm talking about coding in C ...

I understand that (system dependent) int takes 4 bytes or 32 bits of memory.

However, there are two things that I find confused. This part of the memory has a specific memory address associated with it (which allows us to say that it is 32 bits), and if you save this int in a variable, then it also has a name associated with it.

eg. int myInt = 5;

My question is: how and where are the memory address and the name of the variable represented at the bit level? When compiling the code, the compiler basically says: "Ok myInt refers to the address 0xffffff" and essentially replaces the memory address in machine code? Even if that was the case, I'm still confused about how the memory address is represented ...

Hope my confusion is clear enough!

+5
source share
2 answers

Theoretically, the answer is "implementation dependent . " Each C compiler decides the best approach — as long as it shows the correct behavior, it really doesn't matter how you got there.

, , , . , , . : , . , , , .

, . , , , , , , .

  • , , (, "int foo;" ) , ( " 0x482c" ). .

  • , , , .

  • , (, ..), , . ; .

, , , . . , , , - , "Stacktrace: function foo()..." "Stacktrace: 0x4572...".

, #, Ruby Java, , , . , , C , , : " foo?".

+4

: "Ok myInt 0xffffff" ?

myInt , . , myInt , .

myInt , myInt, .

, ...

, . , int .

+1

All Articles