Option Type | Default Value | #pragma options | C | C++ |
-qoption | nomacpstr | MACPSTR | x | x |
Syntax
-qmacpstr | -qnomacpstr MACPSTR | NOMACPSTR
Purpose
Converts Pascal string literals into null-terminated strings
where the first byte contains the length of the string.
Notes
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, the -qmacpstr converts:
"\pABC"
to:
'\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.
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 | 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.
"ABC" "\pDEF"
gives:
"ABCpDEF"
'\p' , 'A' , 'B' , 'C' , '\0'
into a character array does not form a Pascal string literal.
Example
To compile mypascal.c and convert string literals into
null-terminated strings, enter:
xlC mypascal.c -qmacpstr