473,320 Members | 1,744 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,320 software developers and data experts.

volatile const int foo

strictly speaking we can't say that const
means "read only" but instead that it means
"do not modify me please" since an object
can be both modifiable and not modifiable
or volatile and const, right?

and if an implementation chose to put
things that are const in read only memory
if that const thing was also volatile
then in that case, it would not be in
read only memory, correct?

--
nethlek
Nov 14 '05 #1
1 3096
ne*****@tokyo.com (Mantorok Redgormor) writes:
strictly speaking we can't say that const means "read only" but
instead that it means "do not modify me please" since an object can be
both modifiable and not modifiable or volatile and const, right?
Not sure what you mean by that. If you have something like

const int i = 5;

then every attempt to modify `i' is an error. OTOH, if you have

int i = 5;
const int *ip = &i;

you can modify `i' directly, but it's an error to modify it through `ip'
(e.g. by assigning to `*ip').
and if an implementation chose to put things that are const in read
only memory if that const thing was also volatile then in that case,
it would not be in read only memory, correct?


Not necessarily. If you have

const volatile int i = 5;

the implementation could still put `i' in read only memory. Perhaps a
better example is

const volatile int *ip = some_system_specific_initialization ();

It would still be an error to modify `*ip' in any way, but the
implementation would have to assume that the object pointed to can be
changed by something beyond its control. Imagine, for example, that
`some_system_specific_initialization ()' returns the address of a
hardware timer, which is incremented regularly by the hardware, but
cannot be changed by the C program.

Martin
Nov 14 '05 #2

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;
17
by: Radde | last post by:
HI, Can volatile variables be accessed by many processess..or only one process can access it.. Cheers..
2
by: LBJ | last post by:
I have the following C code: //pHeadLoc contains an address that can be modified externally, //therefore it is a volatile pointer to a pointer volatile int** const pHeadLoc = (int**)0x456000; ...
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...
9
by: d.f.s. | last post by:
In the post below, 'copy constructor?', the answers refer to an object declared as const volatile. Now I'm confused. Are those terms not mutually exclusive? const='Hey compiler! This is not...
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...
3
by: C++Liliput | last post by:
It seems that the keyword "volatile" is used to make sure that threads reading (or writing to) the same data should see a consistent picture of the variable i.e. updates made to the common data...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.