macpstr Language Option (C, AIX)

Syntax: Default:
lang(macpstr[, yes])
lang(macpstr, no)
lang(macpstr, no)

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

A Pascal string literal 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.

For example, lang(macpstr, yes) converts:

"/pABC

to

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

The compiler ignores the macpstr option when the lang(dbcs, yes) option is specified because Pascal-string-literal processing is only valid for single-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.

Examples of Pascal String Literals

The compiler replaces trigraph sequences by the corresponding single-character representation. For example:

"??/p pascal string"

becomes:

"\p pascal string"

The following are examples of valid Pascal string literals:

ANSI Mode "\p pascal string"

Each instance of a new-line character and an immediately preceding backslash (\) character is deleted, splicing the physical source lines into logical ones. For example:

"\p pascal \

 string"

Two Pascal string literals are concatenated to form one Pascal string literal. For example:

"\p ABC" "\p DEF"

or

"\p ABC" "DEF"

becomes:

"\06ABCDEF"

For the macro ADDQUOTES:

#define ADDQUOTES (x) #x

where x is:

\p pascal string

or

\p pascal \

 string

becomes:

"\p pascal string"

Note however that:

ADDQUOTES(This is not a "\p pascal string")

becomes:

"This is not a \"\\p pascal string\""
Extended Mode This mode is the same as ANSI mode, except the macro definition would be:
#define ADDQUOTES_Ext (x) "x"

Where x is the same as in the ANSI example:

\p pascal string

\p pascal \

 string

 

String Literal Processing

The following describes how Pascal string literals are processed.



C Compilation: Comparing C and C++ Builds
Configuration Files


Set Build Options
Build


Build Options
Language Options for C