Converts Pascal string literals into null-terminated strings where the first byte contains the length of the string.


Read syntax diagramSkip visual syntax diagram        .-nomacpstr-.
>>- -q--+-macpstr---+------------------------------------------><

See also #pragma options.


A Pascal string literal always contains the characters "\p. The characters \p in the middle of a string do not form a Pascal string literal; the characters must be immediately preceded by the " (double quote) character.

The final length of the Pascal string literal can be no longer than 255 bytes (the maximum length that can fit in a byte).

For example, when the -qmacpstr option is in effect, the compiler converts:



'\03' , 'A' , 'B' , 'C' , '\0'

The compiler ignores the -qmacpstr option when the -qmbcs or -qdbcs option is active because Pascal-string-literal processing is only valid for one-byte characters.

The #pragma options keyword macpstr is only valid at the top of a source file before any C or C++ source statements. If you attempt to use it in the middle of a source file, it is ignored and the compiler issues an error message.

String Literal Processing

The following describes how Pascal string literals are processed.


To compile mypascal.c and convert string literals into null-terminated strings, enter:

xlc mypascal.c -qmacpstr

Related information