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

Feeling kind of stupid about pointers

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

"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
by: Holly | last post by:
I'm trying to validate my code and I can't figure out what kind of doctype I have. The validator can't tell me anything because it can't move beyond the doctype declaration. ...
16
by: cody | last post by:
I have a method that gets called if the user presses a certain button. If the object is in a state that doesn't allow the calling of that method, what should I do? Should I better throw an...
4
by: Scott Smedley | last post by:
Hi all, I'm trying to write a special adaptor iterator for my program. I have *almost* succeeded, though it fails under some circumstances. See the for-loop in main(). Any pointers/help...
11
by: Joseph Turian | last post by:
Fellow hackers, I have a class BuildNode that inherits from class Node. Similarly, I have a class BuildTree that inherits from class Tree. Tree includes a member variable: vector<Node>...
36
by: Hoopster | last post by:
Hello, I know nothing about C++ but want to get started. Is there any good free C++ program that I can try to see if I like programming? I also need a good free compiler. I don't want to...
2
by: Lampa Dario | last post by:
Hi, where is this stupid error in this program? When I execute it, i receive a segmentation fault error. #include <stdio.h> int main(int argc, char *argv, char *env) { int i=0; int l=0; int...
5
by: Frederick Gotham | last post by:
Before I begin, here's a list of assumptions for this particular example: (1) unsigned int has no padding bits, and therefore no invalid bit- patterns or trap representations. (2) All types have...
7
by: RvGrah | last post by:
I'm using the Activated event of my form to run a database query in a backroundWorker, and want to dismiss the call after the first time the form is activated. Based on some excellent advice in an...
7
by: ot_007_2001 | last post by:
Hi, all, For pricticing defination of structure in C, I wrote a small code as follow: #include<stdio.h> struct datastruct { int data;
10
by: Chris Becke | last post by:
In C and in older C++ compilers, you could write code like this void a(void** pp); // declare a function that takes a pointer to a pointer-to-void. struct I {}; // some struct. I *i1,**i2; //...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.