volatile pointers
Robert J. Brown
rj@eli.wariat.org
Sun Feb 23 08:55:00 GMT 1997
>>>>> "Neville" == Neville Mair <nev@snet.net> writes:
Neville> I tried this #define SIMCR (( volatile unsigned short
Neville> *)0Xfffa00)
Neville> This creates a 'volatile pointer' to short. Everytime
Neville> the register (SIMCR) is accessed, the pointer is
Neville> reloaded.
Neville> What is the syntax to create a pointer to a 'volatile
Neville> short'.
Neville> Sorry for the simple question, but I couldn't find an
Neville> answer anywhere else.
Typically, what you want is a pointer that is a constant, but that
points to some hardware memory mapped I/O device register. You say it
in C++ like this:
volatile unsigned short int* const foo = 0xfffa00;
I do not think C has such flexibility in declaring such thins. I
always prefer to declare a const to a #define. A good compiler treats
it the same way when optimizing.
--
-------- "And there came a writing to him from Elijah" [2Ch 21:12] --------
Robert Jay Brown III rj@eli.wariat.org http://eli.wariat.org 1 847 705-0424
Elijah Laboratories Inc.; 37 South Greenwood Avenue; Palatine, IL 60067-6328
----- M o d e l i n g t h e M e t h o d s o f t h e M i n d ------
More information about the crossgcc
mailing list