Thread: Register variable

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    INDIA
    Posts
    64

    Register variable

    can we have interger array as a register variable.I tried that but it shows an error.Is there any way to have the array as a register variable.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    No you can't.

    Using register with a modern compiler is a waste of time. They're perfectly capable of working out what to put in registers and when to do it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    Totally agree with Salem. Nearly all compiler (writers) are smarter than you in such cases. If e.g. MSVC sees that a function accesses the integer i nearly 40 times and it's address is never needed, it will likely put that into a register if possible.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Register variable
    By Lettin03 in forum C Programming
    Replies: 2
    Last Post: 11-20-2007, 06:14 AM
  2. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 01:25 PM
  3. Static global variable acting as global variable?
    By Visu in forum C Programming
    Replies: 2
    Last Post: 07-20-2004, 08:46 AM
  4. Use of variable
    By alice in forum C Programming
    Replies: 8
    Last Post: 06-05-2004, 07:32 AM
  5. Replies: 2
    Last Post: 04-12-2004, 01:37 AM