help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable at specific address


From: Ulrich Lauther
Subject: Re: Variable at specific address
Date: Wed, 17 Aug 2005 12:46:58 +0000 (UTC)

Rolf Magnus <ramagnus@t-online.de> wrote:
: Is there a way to force a global variable to be at a specific memory
: address? I have been looking through the variable attributes list in the
: documentation, but didn't find anything. I want to use this to access some
: special i/o registers that are mapped to specific memory addresses.

What about a reference?

// most ugly and dangeraous code:

int main() {

  int* a = (int*) 0x20000;
  int& b = *a; // b refers to addres 0x20000

  return 0;
}

or - as you asked for a global variable -

int& x = *((int*) 0x20000);
int main() {
  return 0;
}

at least, it compiles.


-- 
        -lauther

[nosave]
----------------------------------------------------------------------------
Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
Siemens CT SE 6         Internet: Ulrich.Lauther@siemens.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]