ROCONST | NOROCONST

Category

Object code control

Pragma equivalent

#pragma variable(var_name, NORENT)

Purpose

Specifies the storage location for constant values.

When the ROCONST compiler option is in effect, the compiler places constants in read-only storage, even if the RENT option is in effect. Placing constant values in read-only memory can improve runtime performance, save storage, and provide shared access.

When the NOROCONST compiler option is in effect, constant values are placed in read/write storage.

Syntax

For C:

Read syntax diagramSkip visual syntax diagram
   .-NOROC-.   
>>-+-ROC---+---------------------------------------------------><

For C++:

Read syntax diagramSkip visual syntax diagram
   .-ROC---.   
>>-+-NOROC-+---------------------------------------------------><

Defaults

For C, the default option is NOROCONST. For C++, the default option is ROCONST.

Usage

The ROCONST option informs the compiler that the const qualifier is respected by the program. Variables defined with the const keyword will not be overridden by a casting operation.

Note that these const variables cannot be exported.

If the specification for a const variable in a #pragma variable directive is in conflict with the option, the #pragma variable takes precedence. The compiler issues an informational message.

If you set the ROCONST option, and if there is a #pragma export for a const variable, the pragma directive takes precedence. The compiler issues an informational message. The variable will still be exported and the variable will be reentrant.

IPA effects

If you specify the ROCONST option during the IPA compile step, the information in the IPA object file reflects the state of each symbol.

If you specify the ROCONST option on the IPA link step, it ignores the option. The reentrant or non-reentrant and const or non-const state of each symbol is maintained during IPA optimization and code generation.

The IPA link step merges and optimizes your application code, and then divides it into sections for code generation. Each of these sections is a partition. The IPA link step uses information from the IPA compile step to determine if a subprogram can be placed in a particular partition. Only compatible subprograms are included in a given partition. Compatible subprograms have the same ROCONST setting.

The ROCONST setting for a partition is set to the specification of the first subprogram that is placed in the partition.

The option value that you specified for each IPA object file on the IPA compile step appears in the IPA link step Compiler Options Map listing section.

The RENT, ROCONST, and ROSTRING options all contribute to the re-entrant or non-reentrant state for each symbol.

The Partition Map sections of the IPA link step listing and the object module END information section display the value of the ROCONST option.

Predefined macros

None.

Related information

For more information on related compiler options, see: