@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-@c 1999, 2000, 2001 Free Software Foundation, Inc.
+@c 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@code{Stdin}, @code{Stdout} and @code{Stderr} as global variables, like
below:
-@example
+@smallexample
FileStream *Stdin = nil;
FileStream *Stdout = nil;
Stderr = [[FileStream new] initWithFd:2];
@}
-/* Other methods here */
+/* @r{Other methods here} */
@@end
-@end example
+@end smallexample
In this example, the initialization of @code{Stdin}, @code{Stdout} and
@code{Stderr} in @code{+initialize} occurs too late. The programmer can
The correct solution of the above problem is to use the @code{+load}
method instead of @code{+initialize}:
-@example
+@smallexample
@@implementation FileStream
Stderr = [[FileStream new] initWithFd:2];
@}
-/* Other methods here */
+/* @r{Other methods here} */
@@end
-@end example
+@end smallexample
The @code{+load} is a method that is not overridden by categories. If a
class and a category of it both implement @code{+load}, both methods are
@c @sp 1
@multitable @columnfractions .25 .75
+@item @code{_Bool}
+@tab @code{B}
@item @code{char}
@tab @code{c}
@item @code{unsigned char}
@tab @code{*}
@item unknown type
@tab @code{?}
+@item Complex types
+@tab @code{j} followed by the inner type. For example @code{_Complex double} is encoded as "jd".
@item bit-fields
@tab @code{b} followed by the starting position of the bit-field, the type of the bit-field and the size of the bit-field (the bit-fields encoding was changed from the NeXT's compiler encoding, see below)
@end multitable
@item Objective-C type
@tab Compiler encoding
@item
-@example
+@smallexample
int a[10];
-@end example
+@end smallexample
@tab @code{[10i]}
@item
-@example
+@smallexample
struct @{
int i;
float f[3];
int b:2;
char c;
@}
-@end example
+@end smallexample
@tab @code{@{?=i[3f]b128i3b131i2c@}}
@end multitable
implement a class whose instances hold a weak pointer reference; the
following class does this:
-@example
+@smallexample
@@interface WeakPointer : Object
@{
@@end
-@end example
+@end smallexample
Weak pointers are supported through a new type character specifier
represented by the @samp{!} character. The
directly by the compiler. You declare a constant string object by
prefixing a C constant string with the character @samp{@@}:
-@example
+@smallexample
id myString = @@"this is a constant string object";
-@end example
+@end smallexample
The constant string objects are by default instances of the
@code{NXConstantString} class which is provided by the GNU Objective-C
The provided class should adhere to a strict structure, the same
as @code{NXConstantString}'s structure:
-@example
+@smallexample
@@interface MyConstantStringClass
@{
@}
@@end
-@end example
+@end smallexample
@code{NXConstantString} inherits from @code{Object}; user class
libraries may choose to inherit the customized constant string class
The keyword @code{@@compatibility_alias} allows you to define a class name
as equivalent to another class name. For example:
-@example
+@smallexample
@@compatibility_alias WOApplication GSWApplication;
-@end example
+@end smallexample
tells the compiler that each time it encounters @code{WOApplication} as
a class name, it should replace it with @code{GSWApplication} (that is,