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.
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.
A register doesn't have an address, if we mean the same thing...
Devoted my life to programming...
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.Originally Posted by onlynishant
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
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.
- Compiler warnings are like "Bridge Out Ahead" warnings. DON'T just ignore them.
- A compiler error is something SO stupid that the compiler genuinely can't carry on with its job. A compiler warning is the compiler saying "Well, that's bloody stupid but if you WANT to ignore me..." and carrying on.
- The best debugging tool in the world is a bunch of printf()'s for everything important around the bits you think might be wrong.