By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,708 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,708 IT Pros & Developers. It's quick & easy.

Feeling kind of stupid about pointers

P: n/a
I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.
Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
PullnOutHair wrote:
I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.


You don't do it in userland. That said.
assert(sizeof(void*) >= sizeof(unsigned long))
void* ptr = reinterpret_cast<void*>(0x30000000UL);
Jul 22 '05 #2

P: n/a
red floyd <no*****@here.dude> wrote in message news:<ID****************@newssvr27.news.prodigy.co m>...
You don't do it in userland. That said.
What do you mean?

assert(sizeof(void*) >= sizeof(unsigned long))
void* ptr = reinterpret_cast<void*>(0x30000000UL);

Jul 22 '05 #3

P: n/a

"PullnOutHair" <di*********@hotmail.com> wrote in message
news:ca**************************@posting.google.c om...
red floyd <no*****@here.dude> wrote in message news:<ID****************@newssvr27.news.prodigy.co m>...
You don't do it in userland. That said.


What do you mean?


http://info.astrian.net/jargon/terms/u/userland.html

Jonathan
Jul 22 '05 #4

P: n/a
PullnOutHair wrote:
I know that I should know how to do this, but for some reason it is
escapeing me right now and I was hoping someone here could help. I
need to setup a pointer to the memory location 0x30000000. I am
working on a linux system that has hardware inputs remapped to that
address and I have to read them. I am just drawing a blank on how to
actually assign the address of a pointer to point to.


Assuming that the platform will allow you, and assuming the pointer is
of type whatever, you can do:

whatever *p = reinterpret_cast<whatever *>(0x30000000);


Regards,

Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #5

P: n/a
Ioannis Vranos posted:
PullnOutHair wrote:
I know that I should know how to do this, but for some reason it is escapeing me right now and I was hoping someone here could help. I need to setup a pointer to the memory location 0x30000000. I am working on a linux system that has hardware inputs remapped to that address and I have to read them. I am just drawing a blank on how to actually assign the address of a pointer to point to.
Assuming that the platform will allow you, and assuming

the pointer is of type whatever, you can do:

whatever *p = reinterpret_cast<whatever *>(0x30000000);


Regards,

Ioannis Vranos

http://www23.brinkster.com/noicys


Should the "volatile" keyword be in there at all?

-JKop
Jul 22 '05 #6

P: n/a
JKop wrote:
Ioannis Vranos posted:

whatever *p = reinterpret_cast<whatever *>(0x30000000);


Should the "volatile" keyword be in there at all?

-JKop


Depends on whether it's data that can change out from underneath him.

My favorite variant of this (embedded system, C, not C++) was:

const volatile unsigned long * const PREGISTER =
(const volatile unsigned long *) 0xC0000000L;

It was a read-only memory mapped register.
Jul 22 '05 #7

P: n/a
JKop wrote:
whatever *p = reinterpret_cast<whatever *>(0x30000000);
Should the "volatile" keyword be in there at all?

volatile is used when the value of the variable can change between reads
outside of the program (e.g. an external thermometer). It has as a
result the compiler to not perform some optimisations.


Regards,

Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.