Thread: volatile keyword

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    347

    volatile keyword

    I have slight confusion. If i use volatile keyword to structure, is it sufficient if i apply to the structure? or i need to apply to individual members also. How does the compiler handle if we give additional volatile keywords than expected.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If you aren't using an embedded compiler, then volatile is only useful with a global sig_atomic_t, to be used in a signal handler. sig_atomic_t - cppreference.com

    If this is for multiple thread access, then you are doing it wrong.

    volatile specifier applies the same way const does. If a structure is const, then all it's members are as well. And if a member of that struct is already const, the compiler understands.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Doubt regarding the volatile keyword
    By 2001goran in forum C Programming
    Replies: 2
    Last Post: 03-14-2013, 12:10 PM
  2. To Volatile, or not to Volatile?
    By EVOEx in forum C++ Programming
    Replies: 16
    Last Post: 05-12-2012, 02:07 PM
  3. Volatile Keyword!!
    By maven in forum C Programming
    Replies: 8
    Last Post: 12-06-2005, 12:56 PM
  4. volatile??
    By jacktibet in forum C Programming
    Replies: 2
    Last Post: 05-29-2003, 03:46 PM
  5. volatile keyword help!!!!
    By penney in forum Linux Programming
    Replies: 2
    Last Post: 03-12-2003, 08:09 AM