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