Why it's not possible to get the address of register variable? if i am right, it must be kept/stored somewhere during run time.:frown:
Printable View
Why it's not possible to get the address of register variable? if i am right, it must be kept/stored somewhere during run time.:frown:
A register doesn't have an address, if we mean the same thing...
If the compiler takes your hint and does use a register, then it is not possible to get the memory address simply because it doesn't have one.Quote:
Originally Posted by onlynishant
But, to be honest, I don't think ANYBODY uses register variables any more. The compiler is much smarter than you with regards to register use, and even in things like the Linux kernel they don't bother.
So the solution to your "problem" of not being able to take their address is just to not declare them 'register' at all. You won't notice any difference, but will be able to take their address, and the compiler will still put them in a register for speed if it thinks it can do so.