|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
I am using the Cx51 Compiler with code banking and variable banking and am having a problem with string allocation. When I declare a constant char string:
const char * far myStr = "Hello";
the compiler locates the pointer in HDATA memory. However, I want all my constants to be located in HCONST.
How can I solve this problem?
Your example defines a pointer in far that points to const char that may be located in any memory space. This is probably not what you want.
The following code example does what you describe:
#pragma STRING (FAR) // locate strings in far const space const char * const far myStr = "Hello";
The STRING directive specifies that the const far memory space is the default location for implicit text strings. And,
const char * const far myStr = "Hello";
defines a pointer in const far that points to const char. Now, all your variables will be located in the HCONST memory class.
Article last edited on: 2007-07-06 01:31:03
Did you find this article helpful? Yes No
How can we improve this article?