aboutsummaryrefslogtreecommitdiff
path: root/gcc/doc/extend.texi
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/doc/extend.texi')
-rw-r--r--gcc/doc/extend.texi72
1 files changed, 71 insertions, 1 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b396227bb84..ebb5e375d22 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -454,6 +454,10 @@ extensions, accepted by GCC in C89 mode and in C++.
* C++ Comments:: C++ comments are recognized.
* Dollar Signs:: Dollar sign is allowed in identifiers.
* Character Escapes:: @samp{\e} stands for the character @key{ESC}.
+@c APPLE LOCAL begin Pascal strings 2001-07-05 zll **
+* Pascal Strings:: Constructing string literals with a Pascal-style
+ length byte.
+@c APPLE LOCAL end Pascal strings 2001-07-05 zll **
* Variable Attributes:: Specifying attributes of variables.
* Type Attributes:: Specifying attributes of types.
* Alignment:: Inquiring about the alignment of a type or variable.
@@ -2389,7 +2393,9 @@ calls are necessary.
@item long_call/short_call
@cindex indirect calls on ARM
This attribute specifies how a particular function is called on
-ARM@. Both attributes override the @option{-mlong-calls} (@pxref{ARM Options})
+@c APPLE LOCAL prune man page
+ARM@. Both attributes override the @option{-mlong-calls}
+@c (@pxref{ARM Options})
command line switch and @code{#pragma long_calls} settings. The
@code{long_call} attribute causes the compiler to always call the
function by first loading its address into a register and then using the
@@ -2965,6 +2971,62 @@ machines, typically because the target assembler does not allow them.
You can use the sequence @samp{\e} in a string or character constant to
stand for the ASCII character @key{ESC}.
+@c APPLE LOCAL begin Pascal strings 2001-07-05 zll **
+@node Pascal Strings
+@section Constructing String Literals with a Pascal-style Length Byte
+@cindex Pascal length byte
+@cindex Pascal strings
+
+Specifying the @w{@option{-fpascal-strings}} option will cause the
+compiler to recognize and construct Pascal-style string literals. This
+functionality is disabled by default; furthermore, its use in new code
+is discouraged.
+
+Pascal string literals take the form @samp{"\pstring"}. The special
+escape sequence @samp{\p} denotes the Pascal length byte for the string,
+and will be replaced at compile time with the number of characters that
+follow. The @samp{\p} may only appear at the beginning of a string
+literal, and may @emph{not} appear in wide string literals or as an
+integral constant.
+
+As is the case with C string literals, Pascal string literals are
+terminated with a NUL character; this character is @emph{not} counted
+when computing the value of the length byte. The maximum @samp{unsigned
+char} value that can be stored in the length byte is also the maximum
+permissible length for the Pascal literal itself. On most target
+platforms, this value is 255 (excluding both the length byte and the
+terminating NUL).
+
+Pascal-style literals are treated by the compiler as being of type
+@samp{const unsigned char []} in C++ and @samp{unsigned char []} (or
+@samp{const unsigned char []}, if the @w{@option{-Wwrite-strings}}
+option is given) in C. Pascal string literals may be used as static
+initializers for @samp{char} arrays (whose elements need not be
+@samp{unsigned} or @samp{const}). They may also be converted to
+@samp{const unsigned char *} and, in the C language to @samp{const char
+*} of any signedness (In C, if the @w{@option{-Wwrite-strings}} is not
+given, then @samp{const} may be omitted as well). For example:
+
+@example
+const unsigned char a[] = "\pHello";
+char b[] = "\pGoodbye";
+const unsigned char *c = "\pHello";
+const signed char *d = "\pHello"; /* error in C++ */
+char *e = "\pHi"; /* error in C++; warning in C with -Wwrite-strings */
+unsigned char *f = "\pHello"; /* error in C++ */
+@end example
+
+@noindent
+In all other respects, Pascal-style string literals behave the same as
+ordinary string literals. For example, if a program attempts to modify
+the conents of a Pascal-style string literal at run-time, the behaviour
+is undefined, unless the @w{@option{-fwritable-strings}} option is used.
+
+Pascal-style literals are useful for calling external routines that
+expect Pascal strings as arguments, as is true with some Apple MacOS
+Toolbox calls.
+@c APPLE LOCAL end Pascal strings 2001-07-05 zll **
+
@node Alignment
@section Inquiring on Alignment of Types or Variables
@cindex alignment
@@ -6422,7 +6484,11 @@ vector unsigned int vec_mulo (vector unsigned short,
vector signed int vec_mulo (vector signed short, vector signed short);
vector float vec_nmsub (vector float, vector float, vector float);
+@c APPLE LOCAL begin fixhtml mrs
+@end smallexample
+@smallexample
+@c APPLE LOCAL end fixhtml mrs
vector float vec_nor (vector float, vector float);
vector signed int vec_nor (vector signed int, vector signed int);
vector unsigned int vec_nor (vector unsigned int, vector unsigned int);
@@ -6988,7 +7054,11 @@ vector signed int vec_any_eq (vector signed char, vector unsigned char);
vector signed int vec_any_eq (vector signed char, vector signed char);
vector signed int vec_any_eq (vector unsigned char, vector signed char);
+@c APPLE LOCAL begin fixhtml mrs
+@end smallexample
+@smallexample
+@c APPLE LOCAL end fixhtml mrs
vector signed int vec_any_eq (vector unsigned char,
vector unsigned char);
vector signed int vec_any_eq (vector signed short,