Thread: volatile int address ??

  1. #1
    Registered User
    Join Date
    Jul 2005

    volatile int address ??

    if i write to macro "SELECT" is it so i am writing to the perticular address as shown below ??
    Can sombody explain what "Volatile" supports here.
    whether typecast should be int or long ?
    #define SELECT        (*( volatile Unsigned int* )(0x106000 )) 
    #define SELECT        (*( volatile unsigned long* )(0x106000 )) 
    which is correct ??
    int is 2 bytes
    Long is 4 bytes

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    volatile tell the compiler that the value of the pointer variable will change some where else in the code

  3. #3
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    I think wording it like that is too ambiguous. The volatile keyword simply tells the compiler that the it may change at any time.
    An example being: when polling a memory mapped address, you may access the same address constant over and over in a loop, generally the compiler would optimize the access out of the loop, but with volatile it knows the value may change at any time from some source.

    That address is often for paging stuff, what are you using it for? Chances are a long is the same size as an int on your computer, but that's assuming your on an x86.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. Replies: 16
    Last Post: 10-29-2006, 05:04 AM
  3. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  4. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM