• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Objective-C and Objective-C++ Dialect Options - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
9<link rel="prev" href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" title="C++ Dialect Options">
10<link rel="next" href="Language-Independent-Options.html#Language-Independent-Options" title="Language Independent Options">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Objective-C-and-Objective-C++-Dialect-Options"></a>
51<a name="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options"></a>
52<p>
53Next:&nbsp;<a rel="next" accesskey="n" href="Language-Independent-Options.html#Language-Independent-Options">Language Independent Options</a>,
54Previous:&nbsp;<a rel="previous" accesskey="p" href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">C++ Dialect Options</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
56<hr>
57</div>
58
59<h3 class="section">3.6 Options Controlling Objective-C and Objective-C++ Dialects</h3>
60
61<p><a name="index-compiler-options_002c-Objective_002dC-and-Objective_002dC_002b_002b-194"></a><a name="index-Objective_002dC-and-Objective_002dC_002b_002b-options_002c-command-line-195"></a><a name="index-options_002c-Objective_002dC-and-Objective_002dC_002b_002b-196"></a>(NOTE: This manual does not describe the Objective-C and Objective-C++
62languages themselves.  See <a href="Standards.html#Standards">Language Standards Supported by GCC</a>, for references.)
63
64 <p>This section describes the command-line options that are only meaningful
65for Objective-C and Objective-C++ programs, but you can also use most of
66the language-independent GNU compiler options. 
67For example, you might compile a file <code>some_class.m</code> like this:
68
69<pre class="smallexample">     gcc -g -fgnu-runtime -O -c some_class.m
70</pre>
71 <p class="noindent">In this example, <samp><span class="option">-fgnu-runtime</span></samp> is an option meant only for
72Objective-C and Objective-C++ programs; you can use the other options with
73any language supported by GCC.
74
75 <p>Note that since Objective-C is an extension of the C language, Objective-C
76compilations may also use options specific to the C front-end (e.g.,
77<samp><span class="option">-Wtraditional</span></samp>).  Similarly, Objective-C++ compilations may use
78C++-specific options (e.g., <samp><span class="option">-Wabi</span></samp>).
79
80 <p>Here is a list of options that are <em>only</em> for compiling Objective-C
81and Objective-C++ programs:
82
83     <dl>
84<dt><code>-fconstant-string-class=</code><var>class-name</var><dd><a name="index-fconstant_002dstring_002dclass-197"></a>Use <var>class-name</var> as the name of the class to instantiate for each
85literal string specified with the syntax <code>@"..."</code>.  The default
86class name is <code>NXConstantString</code> if the GNU runtime is being used, and
87<code>NSConstantString</code> if the NeXT runtime is being used (see below).  The
88<samp><span class="option">-fconstant-cfstrings</span></samp> option, if also present, will override the
89<samp><span class="option">-fconstant-string-class</span></samp> setting and cause <code>@"..."</code> literals
90to be laid out as constant CoreFoundation strings.
91
92     <br><dt><code>-fgnu-runtime</code><dd><a name="index-fgnu_002druntime-198"></a>Generate object code compatible with the standard GNU Objective-C
93runtime.  This is the default for most types of systems.
94
95     <br><dt><code>-fnext-runtime</code><dd><a name="index-fnext_002druntime-199"></a>Generate output compatible with the NeXT runtime.  This is the default
96for NeXT-based systems, including Darwin and Mac OS X.  The macro
97<code>__NEXT_RUNTIME__</code> is predefined if (and only if) this option is
98used.
99
100     <br><dt><code>-fno-nil-receivers</code><dd><a name="index-fno_002dnil_002dreceivers-200"></a>Assume that all Objective-C message dispatches (<code>[receiver
101message:arg]</code>) in this translation unit ensure that the receiver is
102not <code>nil</code>.  This allows for more efficient entry points in the
103runtime to be used.  This option is only available in conjunction with
104the NeXT runtime and ABI version 0 or 1.
105
106     <br><dt><code>-fobjc-abi-version=</code><var>n</var><dd><a name="index-fobjc_002dabi_002dversion-201"></a>Use version <var>n</var> of the Objective-C ABI for the selected runtime. 
107This option is currently supported only for the NeXT runtime.  In that
108case, Version 0 is the traditional (32-bit) ABI without support for
109properties and other Objective-C 2.0 additions.  Version 1 is the
110traditional (32-bit) ABI with support for properties and other
111Objective-C 2.0 additions.  Version 2 is the modern (64-bit) ABI.  If
112nothing is specified, the default is Version 0 on 32-bit target
113machines, and Version 2 on 64-bit target machines.
114
115     <br><dt><code>-fobjc-call-cxx-cdtors</code><dd><a name="index-fobjc_002dcall_002dcxx_002dcdtors-202"></a>For each Objective-C class, check if any of its instance variables is a
116C++ object with a non-trivial default constructor.  If so, synthesize a
117special <code>- (id) .cxx_construct</code> instance method that will run
118non-trivial default constructors on any such instance variables, in order,
119and then return <code>self</code>.  Similarly, check if any instance variable
120is a C++ object with a non-trivial destructor, and if so, synthesize a
121special <code>- (void) .cxx_destruct</code> method that will run
122all such default destructors, in reverse order.
123
124     <p>The <code>- (id) .cxx_construct</code> and <code>- (void) .cxx_destruct</code>
125methods thusly generated will only operate on instance variables
126declared in the current Objective-C class, and not those inherited
127from superclasses.  It is the responsibility of the Objective-C
128runtime to invoke all such methods in an object's inheritance
129hierarchy.  The <code>- (id) .cxx_construct</code> methods will be invoked
130by the runtime immediately after a new object instance is allocated;
131the <code>- (void) .cxx_destruct</code> methods will be invoked immediately
132before the runtime deallocates an object instance.
133
134     <p>As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
135support for invoking the <code>- (id) .cxx_construct</code> and
136<code>- (void) .cxx_destruct</code> methods.
137
138     <br><dt><code>-fobjc-direct-dispatch</code><dd><a name="index-fobjc_002ddirect_002ddispatch-203"></a>Allow fast jumps to the message dispatcher.  On Darwin this is
139accomplished via the comm page.
140
141     <br><dt><code>-fobjc-exceptions</code><dd><a name="index-fobjc_002dexceptions-204"></a>Enable syntactic support for structured exception handling in
142Objective-C, similar to what is offered by C++ and Java.  This option
143is required to use the Objective-C keywords <code>@try</code>,
144<code>@throw</code>, <code>@catch</code>, <code>@finally</code> and
145<code>@synchronized</code>.  This option is available with both the GNU
146runtime and the NeXT runtime (but not available in conjunction with
147the NeXT runtime on Mac OS X 10.2 and earlier).
148
149     <br><dt><code>-fobjc-gc</code><dd><a name="index-fobjc_002dgc-205"></a>Enable garbage collection (GC) in Objective-C and Objective-C++
150programs.  This option is only available with the NeXT runtime; the
151GNU runtime has a different garbage collection implementation that
152does not require special compiler flags.
153
154     <br><dt><code>-fobjc-nilcheck</code><dd><a name="index-fobjc_002dnilcheck-206"></a>For the NeXT runtime with version 2 of the ABI, check for a nil
155receiver in method invocations before doing the actual method call. 
156This is the default and can be disabled using
157<samp><span class="option">-fno-objc-nilcheck</span></samp>.  Class methods and super calls are never
158checked for nil in this way no matter what this flag is set to. 
159Currently this flag does nothing when the GNU runtime, or an older
160version of the NeXT runtime ABI, is used.
161
162     <br><dt><code>-fobjc-std=objc1</code><dd><a name="index-fobjc_002dstd-207"></a>Conform to the language syntax of Objective-C 1.0, the language
163recognized by GCC 4.0.  This only affects the Objective-C additions to
164the C/C++ language; it does not affect conformance to C/C++ standards,
165which is controlled by the separate C/C++ dialect option flags.  When
166this option is used with the Objective-C or Objective-C++ compiler,
167any Objective-C syntax that is not recognized by GCC 4.0 is rejected. 
168This is useful if you need to make sure that your Objective-C code can
169be compiled with older versions of GCC.
170
171     <br><dt><code>-freplace-objc-classes</code><dd><a name="index-freplace_002dobjc_002dclasses-208"></a>Emit a special marker instructing <samp><span class="command">ld(1)</span></samp> not to statically link in
172the resulting object file, and allow <samp><span class="command">dyld(1)</span></samp> to load it in at
173run time instead.  This is used in conjunction with the Fix-and-Continue
174debugging mode, where the object file in question may be recompiled and
175dynamically reloaded in the course of program execution, without the need
176to restart the program itself.  Currently, Fix-and-Continue functionality
177is only available in conjunction with the NeXT runtime on Mac OS X 10.3
178and later.
179
180     <br><dt><code>-fzero-link</code><dd><a name="index-fzero_002dlink-209"></a>When compiling for the NeXT runtime, the compiler ordinarily replaces calls
181to <code>objc_getClass("...")</code> (when the name of the class is known at
182compile time) with static class references that get initialized at load time,
183which improves run-time performance.  Specifying the <samp><span class="option">-fzero-link</span></samp> flag
184suppresses this behavior and causes calls to <code>objc_getClass("...")</code>
185to be retained.  This is useful in Zero-Link debugging mode, since it allows
186for individual class implementations to be modified during program execution. 
187The GNU runtime currently always retains calls to <code>objc_get_class("...")</code>
188regardless of command line options.
189
190     <br><dt><code>-gen-decls</code><dd><a name="index-gen_002ddecls-210"></a>Dump interface declarations for all classes seen in the source file to a
191file named <samp><var>sourcename</var><span class="file">.decl</span></samp>.
192
193     <br><dt><code>-Wassign-intercept </code><span class="roman">(Objective-C and Objective-C++ only)</span><dd><a name="index-Wassign_002dintercept-211"></a><a name="index-Wno_002dassign_002dintercept-212"></a>Warn whenever an Objective-C assignment is being intercepted by the
194garbage collector.
195
196     <br><dt><code>-Wno-protocol </code><span class="roman">(Objective-C and Objective-C++ only)</span><dd><a name="index-Wno_002dprotocol-213"></a><a name="index-Wprotocol-214"></a>If a class is declared to implement a protocol, a warning is issued for
197every method in the protocol that is not implemented by the class.  The
198default behavior is to issue a warning for every method not explicitly
199implemented in the class, even if a method implementation is inherited
200from the superclass.  If you use the <samp><span class="option">-Wno-protocol</span></samp> option, then
201methods inherited from the superclass are considered to be implemented,
202and no warning is issued for them.
203
204     <br><dt><code>-Wselector </code><span class="roman">(Objective-C and Objective-C++ only)</span><dd><a name="index-Wselector-215"></a><a name="index-Wno_002dselector-216"></a>Warn if multiple methods of different types for the same selector are
205found during compilation.  The check is performed on the list of methods
206in the final stage of compilation.  Additionally, a check is performed
207for each selector appearing in a <code>@selector(...)</code>
208expression, and a corresponding method for that selector has been found
209during compilation.  Because these checks scan the method table only at
210the end of compilation, these warnings are not produced if the final
211stage of compilation is not reached, for example because an error is
212found during compilation, or because the <samp><span class="option">-fsyntax-only</span></samp> option is
213being used.
214
215     <br><dt><code>-Wstrict-selector-match </code><span class="roman">(Objective-C and Objective-C++ only)</span><dd><a name="index-Wstrict_002dselector_002dmatch-217"></a><a name="index-Wno_002dstrict_002dselector_002dmatch-218"></a>Warn if multiple methods with differing argument and/or return types are
216found for a given selector when attempting to send a message using this
217selector to a receiver of type <code>id</code> or <code>Class</code>.  When this flag
218is off (which is the default behavior), the compiler will omit such warnings
219if any differences found are confined to types which share the same size
220and alignment.
221
222     <br><dt><code>-Wundeclared-selector </code><span class="roman">(Objective-C and Objective-C++ only)</span><dd><a name="index-Wundeclared_002dselector-219"></a><a name="index-Wno_002dundeclared_002dselector-220"></a>Warn if a <code>@selector(...)</code> expression referring to an
223undeclared selector is found.  A selector is considered undeclared if no
224method with that name has been declared before the
225<code>@selector(...)</code> expression, either explicitly in an
226<code>@interface</code> or <code>@protocol</code> declaration, or implicitly in
227an <code>@implementation</code> section.  This option always performs its
228checks as soon as a <code>@selector(...)</code> expression is found,
229while <samp><span class="option">-Wselector</span></samp> only performs its checks in the final stage of
230compilation.  This also enforces the coding style convention
231that methods and selectors must be declared before being used.
232
233     <br><dt><code>-print-objc-runtime-info</code><dd><a name="index-print_002dobjc_002druntime_002dinfo-221"></a>Generate C header describing the largest structure that is passed by
234value, if any.
235
236 </dl>
237
238 </body></html>
239
240