-qmacpstr

Category

Language element control

Pragma equivalent

#pragma options [no]macpstr

Purpose

Converts Pascal string literals (prefixed by the \p escape sequence) into null-terminated strings in which the first byte contains the length of the string.

For example, when the -qmacpstr option is in effect, the compiler converts:
“\pABC”
to:
'\03' , 'A' , 'B' , 'C' , '\0'

Syntax

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

Defaults

-qnomacpstr

Usage

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, and must be immediately preceded by the " (double quote) character.

Entering the characters:
'\p' , 'A' , 'B' , 'C' , '\0'
into a character array does not form a Pascal string literal.

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 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.

The following describes how Pascal string literals are processed.

Predefined macros

None.

Examples

To compile mypascal.c and convert string literals into Pascal-style strings, enter:
xlc mypascal.c -qmacpstr

Related information