-qroconst

Purpose

Specifies the storage location for constant values.

When roconst is in effect, constants are placed in read-only storage. When noroconst is in effect, constants are placed in read/write storage.

Syntax

Read syntax diagramSkip visual syntax diagram
        .-roconst---.   
>>- -q--+-noroconst-+------------------------------------------><

Defaults

  • C only -qroconst for all compiler invocations except cc and its derivatives. -qnoroconst for the cc invocation and its derivatives.
  • C++ only -qroconst

Usage

Placing constant values in read-only memory can improve runtime performance, save storage, and provide shared access. However, code that attempts to modify a read-only constant value generates a memory error.

"Constant" in the context of the -qroconst option refers to variables that are qualified by const, including const-qualified characters, integers, floats, enumerations, structures, unions, and arrays. The following constructs are not affected by this option:
  • Variables qualified with volatile and aggregates (such as a structure or a union) that contain volatile variables
  • Pointers and complex aggregates containing pointer members
  • Automatic and static types with block scope
  • Uninitialized types
  • Regular structures with all members qualified by const
  • Initializers that are addresses, or initializers that are cast to non-address values

The -qroconst option does not imply the -qro option. Both options must be specified if you want to specify storage characteristics of both string literals (-qro) and constant values (-qroconst).

Predefined macros

None.

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us