Rolf Magnus <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to