Keil Logo


Information in this article applies to:

  • C166 All Versions
  • C251 All Versions


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


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

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

Last Reviewed: Wednesday, July 20, 2005

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.