ARM Technical Support Knowledge Articles

LOCATING POINTERS IN ROM

Applies to: General Topics

Answer


Information in this article applies to:


QUESTION

How do I locate pointers in ROM? When I apply const to the pointer it is still located in RAM space.

ANSWER

When you declare a pointer, there are two memory areas that you must consider: the memory space where the pointer resides and the memory space where the object pointed to resides.

To locate the pointer in ROM, you must declare is to be const. For example:

const char cc=1;            // place a constant variable in const ROM
const char *p = &cc; // pointer in RAM that addresses const char
const char *const cp = &cc; // pointer in const ROM that addresses const
char

struct s {
const char *p; // a struct with a pointer to const ROM
};

struct s vs = {&cc}; // place a struct in RAM
const struct s cs = {&cc}; // place a struct in const ROM

Article last edited on: 2005-07-20 15:57:39

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential