473,378 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

volatile and pointer functions

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

Aug 10 '06 #1
6 2205

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

Aug 10 '06 #2
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!!
Aug 10 '06 #3
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!!
Aug 10 '06 #4
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/

Aug 10 '06 #5
"venky" <ve****************@gmail.comwrites:
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) ks***@mib.org <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.
Aug 10 '06 #6
ra*******************@gmail.com 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
Aug 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: newsock | last post by:
Why need to qualify a member function "volatile"? Why need to qualify a object "volatile"? When need to "const_cast" away "volatile" of an object and a member function? I also saw some code...
4
by: dwaach | last post by:
Hi, I have something like. struct X {}; X ox; X* pox=&ox; X*& volatile r =pox;
8
by: Tim Rentsch | last post by:
Here's another question related to 'volatile'. Consider the following: int x; void foo(){ int y; y = (volatile int) x;
5
by: ben | last post by:
Hello All, I am trying to make sense of a bit of syntax, is there a guru out there that can clear this up for me. I have a buffer declared as static volatile u8 buffer; and I have a...
9
by: mlimber | last post by:
I am using placement new to locate a shared data structure at a particular location in shared memory. The problem is that when I access the data on one of the two processors sharing it, I don't get...
6
by: red floyd | last post by:
I have a struct that maps onto a set of memory mapped registers. I access this via a pointer. Is it better to declare it as pointer to a volatile struct, or to declare the individual members as...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
3
by: Rakesh Kumar | last post by:
Hi - I am actually trying to get my feet in multi-threaded C++ programming. While I am aware that the C++ standard does not talk about threads (at least, for now - in C++03) - my question is more...
10
by: S James S Stapleton | last post by:
Is volatile necessary anymore? I have a two-thread piece of code I've been testing to figure out what volatile does (fairly simple code, uses pthreads). I have an update thread (variables passed as...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.