Keil Logo

STRING Compiler Directive

Abbreviation

None.

Arguments

)(CODE), (XDATA), or (FAR)

Default

STRING (CODE)

µVision

Options — C51 — Misc controls.

Description

The STRING directive specifies the memory type used for implicit strings. By default, implicit strings are located in code memory. For example:

void main (void) {
  printf ("hello world\n");
}

in this example, the string "hello world" is located in code memory.

The STRING directive changes the default location for implicitly located strings. This directive must be used carefully, since existing programs might use memory typed pointers to access strings.

One good reason to consider changing the default location of implicit strings (to the xdata or far memory areas) to avoid using code banking. This directive is useful especially for extended 8051 devices like the NXP 80C51MX.

Option Description
CODE Implicit strings are located in code space. This is the default setting of the Cx51 Compiler.
XDATA Implicit strings are located in const xdata space.
FAR Implicit strings are located in const far space.

Note

  • The XDATA and FAR options require that you use the OMF2 directive.
See Also

XCROM

Example
C51 SAMPLE.C STRING (XDATA)

#pragma STRING (FAR)
  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.