Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > volatile and pointer functions

Reply
Thread Tools

volatile and pointer functions

 
 
venky
Guest
Posts: n/a
 
      08-10-2006
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

 
Reply With Quote
 
 
 
 
manmohan
Guest
Posts: n/a
 
      08-10-2006

venky wrote:
> 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!!

 
Reply With Quote
 
 
 
 
ramasubramanian.rahul@gmail.com
Guest
Posts: n/a
 
      08-10-2006
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
manmohan wrote:

> venky wrote:
> > 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!!


 
Reply With Quote
 
ramasubramanian.rahul@gmail.com
Guest
Posts: n/a
 
      08-10-2006
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
manmohan wrote:

> venky wrote:
> > 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!!


 
Reply With Quote
 
Chris Dollin
Guest
Posts: n/a
 
      08-10-2006
venky wrote:

> 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.

--
Chris "seeker" Dollin
"Who do you serve, and who do you trust?" /Crusade/

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-10-2006
"venky" <(E-Mail Removed)> writes:
> 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.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Thad Smith
Guest
Posts: n/a
 
      08-11-2006
(E-Mail Removed) wrote:

> 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.

--
Thad
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pointer-to-member data and pointer-to-member functions and access specifiers Stephen Howe C++ 2 11-06-2012 12:32 PM
Re: volatile keyword for C++ member functions Tristan Wibberley C++ 3 01-01-2008 11:05 PM
volatile keyword for C++ member functions Rakesh Kumar C++ 15 12-31-2007 03:46 PM
Re: volatile keyword for C++ member functions Tristan Wibberley C++ 0 12-31-2007 10:10 AM
Use of the Volatile keyword for a pointer to a volatile memory block ben C Programming 5 01-11-2005 05:38 PM



Advertisments