1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Volatile Keyword

Discussion in 'C' started by kvsn1991, Apr 22, 2016.

  1. kvsn1991

    kvsn1991 New Member

    Joined:
    Apr 22, 2016
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi sir,
    what is volatile keyword and how it's works?
    volatile with const qualifier

    i was read some read some articles but i didn't fully understand that concept.can you explain with some examples
     
  2. ChavezAngela

    ChavezAngela New Member

    Joined:
    Jun 24, 2016
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    London
    A variable should be declared volatile whenever its value could change unexpectedly. In practice, only three types of variables could change:

    1. Memory-mapped peripheral registers
    2. Global variables modified by an interrupt service routine
    3. Global variables accessed by multiple tasks within a multi-threaded application

    We'll talk about each of these cases in the sections that follow.
     
  3. senthil_a4nlabs

    senthil_a4nlabs New Member

    Joined:
    Aug 27, 2016
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Male
    it is keyword which does not work if it having any moderations..
     
  4. persysweb

    persysweb Member

    Joined:
    Aug 1, 2017
    Messages:
    70
    Likes Received:
    12
    Trophy Points:
    8
    Location:
    India
    Home Page:
    Volatile is a qualifier that is applied to a variable when it is declared. It tells the compiler that the value of the variable may change at any time-without any action being taken by the code the compiler finds nearby. Syntax:
    To declare a variable volatile, include the keyword volatile before or after the data type in the variable definition.
    volatile int foo;
    int volatile foo;
     

Share This Page