volatile and pointer functions

V

venky

Hi all,

I'm new to group n c. i want to know in detail about volatile qualifier
and pointer to functions with examples.

thank you
 
M

manmohan

venky said:
Hi all,

I'm new to group n c. i want to know in detail about volatile qualifier
and pointer to functions with examples.

thank you

For a better and exhaustive explanation look through
http://www.c-faq.com

The keyword volatile allow you to declare variables (or pointers
to data) which you promise not to change, (or which might change in
unexpected ways behind the program's back.) A nice example would be
some variable in your routine, which is to be accessed by the
clock-routine of the system and constantly updated.This variable is not
supposed to be accessed or modified in scopes internal to your
program;rather is done externally!!

Regarding pointers to functions too look through same link!!
I would recommend you to go through Clockwise/spiral Rule of
complicated declarations and working of "cdecl".

Hope it helps!!
 
R

ramasubramanian.rahul

hi
in simple the volatile keyword tells the compiler to leave the
variable alone.. and not to agressively optimise it ...
the variable may be used in memory mapped io shared memory
implementation etc...
a simple way to understand this would be to do the following


int main ()
{
int x ;
volatile int y ;
x = 1 ;
x= 1 ;
x= 1 ;
y = 1 ;
y = 1 ;
y =1 ;
}

compile this code with optimiser int a .s file using
cc -S -o prog.c

view the prog.s file..
you will see that for x .. the compiler ignores the repeated
commands.. but it faithfully executes all the redundant commands for
the var y...
regards
rahul


w said:
venky said:
Hi all,

I'm new to group n c. i want to know in detail about volatile qualifier
and pointer to functions with examples.

thank you

For a better and exhaustive explanation look through
http://www.c-faq.com

The keyword volatile allow you to declare variables (or pointers
to data) which you promise not to change, (or which might change in
unexpected ways behind the program's back.) A nice example would be
some variable in your routine, which is to be accessed by the
clock-routine of the system and constantly updated.This variable is not
supposed to be accessed or modified in scopes internal to your
program;rather is done externally!!

Regarding pointers to functions too look through same link!!
I would recommend you to go through Clockwise/spiral Rule of
complicated declarations and working of "cdecl".

Hope it helps!!
 
R

ramasubramanian.rahul

hi
in simple the volatile keyword tells the compiler to leave the
variable alone.. and not to agressively optimise it ...
the variable may be used in memory mapped io shared memory
implementation etc...
a simple way to understand this would be to do the following


int main ()
{
int x ;
volatile int y ;
x = 1 ;
x= 1 ;
x= 1 ;
y = 1 ;
y = 1 ;
y =1 ;
}

compile this code with optimiser int a .s file using
cc -S -o prog.c

view the prog.s file..
you will see that for x .. the compiler ignores the repeated
commands.. but it faithfully executes all the redundant commands for
the var y...
regards
rahul


w said:
venky said:
Hi all,

I'm new to group n c. i want to know in detail about volatile qualifier
and pointer to functions with examples.

thank you

For a better and exhaustive explanation look through
http://www.c-faq.com

The keyword volatile allow you to declare variables (or pointers
to data) which you promise not to change, (or which might change in
unexpected ways behind the program's back.) A nice example would be
some variable in your routine, which is to be accessed by the
clock-routine of the system and constantly updated.This variable is not
supposed to be accessed or modified in scopes internal to your
program;rather is done externally!!

Regarding pointers to functions too look through same link!!
I would recommend you to go through Clockwise/spiral Rule of
complicated declarations and working of "cdecl".

Hope it helps!!
 
C

Chris Dollin

venky said:
I'm new to group n c. i want to know in detail about volatile qualifier
Why?

and pointer to functions with examples.

Why?

I ask because it's much easier to provide useful answers if we know the
context of the question.
 
K

Keith Thompson

venky said:
I'm new to group n c. i want to know in detail about volatile qualifier
and pointer to functions with examples.

Read a good C textbook.
 
T

Thad Smith

in simple the volatile keyword tells the compiler to leave the
variable alone.. and not to agressively optimise it ...

More explicitly, it specifies that each access of the variable must be
performed as written between the enclosing sequence points and not at
any other times. What constitutes an access is implementation-defined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top