Like Tree1Likes
  • 1 Post By ledow

Register variable storage

This is a discussion on Register variable storage within the C Programming forums, part of the General Programming Boards category; Why it's not possible to get the address of register variable? if i am right, it must be kept/stored somewhere ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    2

    Unhappy Register variable storage

    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.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    A register doesn't have an address, if we mean the same thing...
    Devoted my life to programming...

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,712
    Quote Originally Posted by onlynishant
    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.
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User ledow's Avatar
    Join Date
    Dec 2011
    Posts
    435
    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.
    Salem likes this.

    - 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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. address of register variable
    By siperi in forum C Programming
    Replies: 15
    Last Post: 11-08-2010, 01:26 PM
  2. variable stored in register or not ???
    By dhondi in forum C Programming
    Replies: 3
    Last Post: 11-03-2009, 12:03 PM
  3. Register variable
    By karthigayan in forum C Programming
    Replies: 2
    Last Post: 05-30-2009, 03:41 AM
  4. Register variable
    By Lettin03 in forum C Programming
    Replies: 2
    Last Post: 11-20-2007, 05:14 AM
  5. Register variable... where are you?
    By pollopinolo in forum C Programming
    Replies: 7
    Last Post: 12-28-2005, 08:09 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21