Keil™, An ARM® Company

Technical Support

C166: CONSTANTS IN SPECIFIC MEMORY AREAS


Information in this article applies to:

  • C166 Version 4.24 or higher

QUESTION

I have a large pointer array for text constants. Here is a simplified example:

const unsigned char *text[]= { "text1", "text2", "text3", };

However, this text is allocated in NCONST (near) memory. I would like to have this text in other ROM spaces, for example in HCONST (huge), since there is no more space in my NCONST space. How may I achieve that?

ANSWER

Just specify the correct memory type in your definition. For example:

unsigned char const huge *text[]= { "text1", "text2", "text3", };  // for HCONST
unsigned char const far *text[]= { "text1", "text2", "text3", };   // for FCONST

Note that this works only if you are using C166 Version 4.24 or higher.

To access such variables you can use the following functions:

  • For far space use fstrxxx and fmemxxx functions.
  • For huge space use hstrxxx and hmemxxx functions.
  • For xhuge space use xstrxxx and xmemxxx functions.

SEE ALSO

Last Reviewed: Saturday, April 24, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure