#pragma strings

Purpose

Specifies the storage type for string literals.

Syntax

Read syntax diagramSkip visual syntax diagram
Pragma syntax

                          .-readonly--.      
>>-#--pragma--strings--(--+-writable--+--)---------------------><
                          '-writeable-'      

Defaults

C and C++ strings are read-only.

Parameters

readonly
String literals are to be placed in read-only memory.
writeable
String literals are to be placed in read-write memory.
writable
A synonym of writeable.

Usage

Placing string literals in read-only memory can improve runtime performance and save storage. However, code that attempts to modify a read-only string literal may generate a memory error.

The pragma must appear before any source statements in a file.

IPA effects

During the IPA link step, the compiler compares the #pragma strings specifications for individual translation units. If it finds differences, it treats the strings as if you specified #pragma strings(writeable) for all translation units.

Related information

  • The ROSTRINGS option in the z/OS® XL C/C++ User's Guide.