variable stored in register or not ???

This is a discussion on variable stored in register or not ??? within the C Programming forums, part of the General Programming Boards category; I stumbled at an assignment that "How do we get to know whether variable stored in register or not, programmatically ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    1

    Question variable stored in register or not ???

    I stumbled at an assignment that

    "How do we get to know whether variable stored in register or not, programmatically ?"

    Please give me any idea, If anyone already done this one.

    Thanks in Advance
    Srikanth Dhondi
    Last edited by dhondi; 11-03-2009 at 12:29 PM.

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by dhondi View Post
    I know how to use storage classes well, I have an assignment that

    "How do we get to know whether variable stored in register or not, programmatically ?"

    Thanks in Advance
    Srikanth Dhondi
    You don't have any way of knowing that. What does "programmatically" mean in this context?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    There is a storage class specifier called register, but as far as I know that only works as a suggestion for the compiler, ie it may not be stored in a register anyway.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,031
    The only way of knowing it is looking at the assembly of the compiled code. It is impossible to do programatically, if it means finding out so via code. Remember that C knows nothing about the process architecture or its registers. It is simply a high-level language that is translated into instructions for the cpu.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 04:31 PM
  2. variable being reset
    By FoodDude in forum C++ Programming
    Replies: 1
    Last Post: 09-15-2005, 01:30 PM
  3. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  4. 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
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM

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