<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
<html>
|
<!-- Copyright (C) 1988-2016 Free Software Foundation, Inc.
|
|
Permission is granted to copy, distribute and/or modify this document
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
any later version published by the Free Software Foundation; with the
|
Invariant Sections being "Funding Free Software", the Front-Cover
|
Texts being (a) (see below), and with the Back-Cover Texts being (b)
|
(see below). A copy of the license is included in the section entitled
|
"GNU Free Documentation License".
|
|
(a) The FSF's Front-Cover Text is:
|
|
A GNU Manual
|
|
(b) The FSF's Back-Cover Text is:
|
|
You have freedom to copy and modify this GNU Manual, like GNU
|
software. Copies published by the Free Software Foundation raise
|
funds for GNU development. -->
|
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
|
<head>
|
<title>Using the GNU Compiler Collection (GCC): Objective-C and Objective-C++ Dialect Options</title>
|
|
<meta name="description" content="Using the GNU Compiler Collection (GCC): Objective-C and Objective-C++ Dialect Options">
|
<meta name="keywords" content="Using the GNU Compiler Collection (GCC): Objective-C and Objective-C++ Dialect Options">
|
<meta name="resource-type" content="document">
|
<meta name="distribution" content="global">
|
<meta name="Generator" content="makeinfo">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<link href="index.html#Top" rel="start" title="Top">
|
<link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
<link href="Invoking-GCC.html#Invoking-GCC" rel="up" title="Invoking GCC">
|
<link href="Diagnostic-Message-Formatting-Options.html#Diagnostic-Message-Formatting-Options" rel="next" title="Diagnostic Message Formatting Options">
|
<link href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" rel="prev" title="C++ Dialect Options">
|
<style type="text/css">
|
<!--
|
a.summary-letter {text-decoration: none}
|
blockquote.smallquotation {font-size: smaller}
|
div.display {margin-left: 3.2em}
|
div.example {margin-left: 3.2em}
|
div.indentedblock {margin-left: 3.2em}
|
div.lisp {margin-left: 3.2em}
|
div.smalldisplay {margin-left: 3.2em}
|
div.smallexample {margin-left: 3.2em}
|
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
|
div.smalllisp {margin-left: 3.2em}
|
kbd {font-style:oblique}
|
pre.display {font-family: inherit}
|
pre.format {font-family: inherit}
|
pre.menu-comment {font-family: serif}
|
pre.menu-preformatted {font-family: serif}
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
pre.smallexample {font-size: smaller}
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
pre.smalllisp {font-size: smaller}
|
span.nocodebreak {white-space:nowrap}
|
span.nolinebreak {white-space:nowrap}
|
span.roman {font-family:serif; font-weight:normal}
|
span.sansserif {font-family:sans-serif; font-weight:normal}
|
ul.no-bullet {list-style: none}
|
-->
|
</style>
|
|
|
</head>
|
|
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
|
<a name="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options"></a>
|
<div class="header">
|
<p>
|
Next: <a href="Diagnostic-Message-Formatting-Options.html#Diagnostic-Message-Formatting-Options" accesskey="n" rel="next">Diagnostic Message Formatting Options</a>, Previous: <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" accesskey="p" rel="prev">C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
|
</div>
|
<hr>
|
<a name="Options-Controlling-Objective_002dC-and-Objective_002dC_002b_002b-Dialects"></a>
|
<h3 class="section">3.6 Options Controlling Objective-C and Objective-C++ Dialects</h3>
|
|
<a name="index-compiler-options_002c-Objective_002dC-and-Objective_002dC_002b_002b"></a>
|
<a name="index-Objective_002dC-and-Objective_002dC_002b_002b-options_002c-command_002dline"></a>
|
<a name="index-options_002c-Objective_002dC-and-Objective_002dC_002b_002b"></a>
|
<p>(NOTE: This manual does not describe the Objective-C and Objective-C++
|
languages themselves. See <a href="Standards.html#Standards">Language Standards
|
Supported by GCC</a>, for references.)
|
</p>
|
<p>This section describes the command-line options that are only meaningful
|
for Objective-C and Objective-C++ programs. You can also use most of
|
the language-independent GNU compiler options.
|
For example, you might compile a file <samp>some_class.m</samp> like this:
|
</p>
|
<div class="smallexample">
|
<pre class="smallexample">gcc -g -fgnu-runtime -O -c some_class.m
|
</pre></div>
|
|
<p>In this example, <samp>-fgnu-runtime</samp> is an option meant only for
|
Objective-C and Objective-C++ programs; you can use the other options with
|
any language supported by GCC.
|
</p>
|
<p>Note that since Objective-C is an extension of the C language, Objective-C
|
compilations may also use options specific to the C front-end (e.g.,
|
<samp>-Wtraditional</samp>). Similarly, Objective-C++ compilations may use
|
C++-specific options (e.g., <samp>-Wabi</samp>).
|
</p>
|
<p>Here is a list of options that are <em>only</em> for compiling Objective-C
|
and Objective-C++ programs:
|
</p>
|
<dl compact="compact">
|
<dt><code>-fconstant-string-class=<var>class-name</var></code></dt>
|
<dd><a name="index-fconstant_002dstring_002dclass"></a>
|
<p>Use <var>class-name</var> as the name of the class to instantiate for each
|
literal string specified with the syntax <code>@"…"</code>. The default
|
class name is <code>NXConstantString</code> if the GNU runtime is being used, and
|
<code>NSConstantString</code> if the NeXT runtime is being used (see below). The
|
<samp>-fconstant-cfstrings</samp> option, if also present, overrides the
|
<samp>-fconstant-string-class</samp> setting and cause <code>@"…"</code> literals
|
to be laid out as constant CoreFoundation strings.
|
</p>
|
</dd>
|
<dt><code>-fgnu-runtime</code></dt>
|
<dd><a name="index-fgnu_002druntime"></a>
|
<p>Generate object code compatible with the standard GNU Objective-C
|
runtime. This is the default for most types of systems.
|
</p>
|
</dd>
|
<dt><code>-fnext-runtime</code></dt>
|
<dd><a name="index-fnext_002druntime"></a>
|
<p>Generate output compatible with the NeXT runtime. This is the default
|
for NeXT-based systems, including Darwin and Mac OS X. The macro
|
<code>__NEXT_RUNTIME__</code> is predefined if (and only if) this option is
|
used.
|
</p>
|
</dd>
|
<dt><code>-fno-nil-receivers</code></dt>
|
<dd><a name="index-fno_002dnil_002dreceivers"></a>
|
<p>Assume that all Objective-C message dispatches (<code>[receiver
|
message:arg]</code>) in this translation unit ensure that the receiver is
|
not <code>nil</code>. This allows for more efficient entry points in the
|
runtime to be used. This option is only available in conjunction with
|
the NeXT runtime and ABI version 0 or 1.
|
</p>
|
</dd>
|
<dt><code>-fobjc-abi-version=<var>n</var></code></dt>
|
<dd><a name="index-fobjc_002dabi_002dversion"></a>
|
<p>Use version <var>n</var> of the Objective-C ABI for the selected runtime.
|
This option is currently supported only for the NeXT runtime. In that
|
case, Version 0 is the traditional (32-bit) ABI without support for
|
properties and other Objective-C 2.0 additions. Version 1 is the
|
traditional (32-bit) ABI with support for properties and other
|
Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If
|
nothing is specified, the default is Version 0 on 32-bit target
|
machines, and Version 2 on 64-bit target machines.
|
</p>
|
</dd>
|
<dt><code>-fobjc-call-cxx-cdtors</code></dt>
|
<dd><a name="index-fobjc_002dcall_002dcxx_002dcdtors"></a>
|
<p>For each Objective-C class, check if any of its instance variables is a
|
C++ object with a non-trivial default constructor. If so, synthesize a
|
special <code>- (id) .cxx_construct</code> instance method which runs
|
non-trivial default constructors on any such instance variables, in order,
|
and then return <code>self</code>. Similarly, check if any instance variable
|
is a C++ object with a non-trivial destructor, and if so, synthesize a
|
special <code>- (void) .cxx_destruct</code> method which runs
|
all such default destructors, in reverse order.
|
</p>
|
<p>The <code>- (id) .cxx_construct</code> and <code>- (void) .cxx_destruct</code>
|
methods thusly generated only operate on instance variables
|
declared in the current Objective-C class, and not those inherited
|
from superclasses. It is the responsibility of the Objective-C
|
runtime to invoke all such methods in an object’s inheritance
|
hierarchy. The <code>- (id) .cxx_construct</code> methods are invoked
|
by the runtime immediately after a new object instance is allocated;
|
the <code>- (void) .cxx_destruct</code> methods are invoked immediately
|
before the runtime deallocates an object instance.
|
</p>
|
<p>As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
|
support for invoking the <code>- (id) .cxx_construct</code> and
|
<code>- (void) .cxx_destruct</code> methods.
|
</p>
|
</dd>
|
<dt><code>-fobjc-direct-dispatch</code></dt>
|
<dd><a name="index-fobjc_002ddirect_002ddispatch"></a>
|
<p>Allow fast jumps to the message dispatcher. On Darwin this is
|
accomplished via the comm page.
|
</p>
|
</dd>
|
<dt><code>-fobjc-exceptions</code></dt>
|
<dd><a name="index-fobjc_002dexceptions"></a>
|
<p>Enable syntactic support for structured exception handling in
|
Objective-C, similar to what is offered by C++ and Java. This option
|
is required to use the Objective-C keywords <code>@try</code>,
|
<code>@throw</code>, <code>@catch</code>, <code>@finally</code> and
|
<code>@synchronized</code>. This option is available with both the GNU
|
runtime and the NeXT runtime (but not available in conjunction with
|
the NeXT runtime on Mac OS X 10.2 and earlier).
|
</p>
|
</dd>
|
<dt><code>-fobjc-gc</code></dt>
|
<dd><a name="index-fobjc_002dgc"></a>
|
<p>Enable garbage collection (GC) in Objective-C and Objective-C++
|
programs. This option is only available with the NeXT runtime; the
|
GNU runtime has a different garbage collection implementation that
|
does not require special compiler flags.
|
</p>
|
</dd>
|
<dt><code>-fobjc-nilcheck</code></dt>
|
<dd><a name="index-fobjc_002dnilcheck"></a>
|
<p>For the NeXT runtime with version 2 of the ABI, check for a nil
|
receiver in method invocations before doing the actual method call.
|
This is the default and can be disabled using
|
<samp>-fno-objc-nilcheck</samp>. Class methods and super calls are never
|
checked for nil in this way no matter what this flag is set to.
|
Currently this flag does nothing when the GNU runtime, or an older
|
version of the NeXT runtime ABI, is used.
|
</p>
|
</dd>
|
<dt><code>-fobjc-std=objc1</code></dt>
|
<dd><a name="index-fobjc_002dstd"></a>
|
<p>Conform to the language syntax of Objective-C 1.0, the language
|
recognized by GCC 4.0. This only affects the Objective-C additions to
|
the C/C++ language; it does not affect conformance to C/C++ standards,
|
which is controlled by the separate C/C++ dialect option flags. When
|
this option is used with the Objective-C or Objective-C++ compiler,
|
any Objective-C syntax that is not recognized by GCC 4.0 is rejected.
|
This is useful if you need to make sure that your Objective-C code can
|
be compiled with older versions of GCC.
|
</p>
|
</dd>
|
<dt><code>-freplace-objc-classes</code></dt>
|
<dd><a name="index-freplace_002dobjc_002dclasses"></a>
|
<p>Emit a special marker instructing <code>ld(1)</code> not to statically link in
|
the resulting object file, and allow <code>dyld(1)</code> to load it in at
|
run time instead. This is used in conjunction with the Fix-and-Continue
|
debugging mode, where the object file in question may be recompiled and
|
dynamically reloaded in the course of program execution, without the need
|
to restart the program itself. Currently, Fix-and-Continue functionality
|
is only available in conjunction with the NeXT runtime on Mac OS X 10.3
|
and later.
|
</p>
|
</dd>
|
<dt><code>-fzero-link</code></dt>
|
<dd><a name="index-fzero_002dlink"></a>
|
<p>When compiling for the NeXT runtime, the compiler ordinarily replaces calls
|
to <code>objc_getClass("…")</code> (when the name of the class is known at
|
compile time) with static class references that get initialized at load time,
|
which improves run-time performance. Specifying the <samp>-fzero-link</samp> flag
|
suppresses this behavior and causes calls to <code>objc_getClass("…")</code>
|
to be retained. This is useful in Zero-Link debugging mode, since it allows
|
for individual class implementations to be modified during program execution.
|
The GNU runtime currently always retains calls to <code>objc_get_class("…")</code>
|
regardless of command-line options.
|
</p>
|
</dd>
|
<dt><code>-fno-local-ivars</code></dt>
|
<dd><a name="index-fno_002dlocal_002divars"></a>
|
<a name="index-flocal_002divars"></a>
|
<p>By default instance variables in Objective-C can be accessed as if
|
they were local variables from within the methods of the class they’re
|
declared in. This can lead to shadowing between instance variables
|
and other variables declared either locally inside a class method or
|
globally with the same name. Specifying the <samp>-fno-local-ivars</samp>
|
flag disables this behavior thus avoiding variable shadowing issues.
|
</p>
|
</dd>
|
<dt><code>-fivar-visibility=<span class="roman">[</span>public<span class="roman">|</span>protected<span class="roman">|</span>private<span class="roman">|</span>package<span class="roman">]</span></code></dt>
|
<dd><a name="index-fivar_002dvisibility"></a>
|
<p>Set the default instance variable visibility to the specified option
|
so that instance variables declared outside the scope of any access
|
modifier directives default to the specified visibility.
|
</p>
|
</dd>
|
<dt><code>-gen-decls</code></dt>
|
<dd><a name="index-gen_002ddecls"></a>
|
<p>Dump interface declarations for all classes seen in the source file to a
|
file named <samp><var>sourcename</var>.decl</samp>.
|
</p>
|
</dd>
|
<dt><code>-Wassign-intercept <span class="roman">(Objective-C and Objective-C++ only)</span></code></dt>
|
<dd><a name="index-Wassign_002dintercept"></a>
|
<a name="index-Wno_002dassign_002dintercept"></a>
|
<p>Warn whenever an Objective-C assignment is being intercepted by the
|
garbage collector.
|
</p>
|
</dd>
|
<dt><code>-Wno-protocol <span class="roman">(Objective-C and Objective-C++ only)</span></code></dt>
|
<dd><a name="index-Wno_002dprotocol"></a>
|
<a name="index-Wprotocol"></a>
|
<p>If a class is declared to implement a protocol, a warning is issued for
|
every method in the protocol that is not implemented by the class. The
|
default behavior is to issue a warning for every method not explicitly
|
implemented in the class, even if a method implementation is inherited
|
from the superclass. If you use the <samp>-Wno-protocol</samp> option, then
|
methods inherited from the superclass are considered to be implemented,
|
and no warning is issued for them.
|
</p>
|
</dd>
|
<dt><code>-Wselector <span class="roman">(Objective-C and Objective-C++ only)</span></code></dt>
|
<dd><a name="index-Wselector"></a>
|
<a name="index-Wno_002dselector"></a>
|
<p>Warn if multiple methods of different types for the same selector are
|
found during compilation. The check is performed on the list of methods
|
in the final stage of compilation. Additionally, a check is performed
|
for each selector appearing in a <code>@selector(…)</code>
|
expression, and a corresponding method for that selector has been found
|
during compilation. Because these checks scan the method table only at
|
the end of compilation, these warnings are not produced if the final
|
stage of compilation is not reached, for example because an error is
|
found during compilation, or because the <samp>-fsyntax-only</samp> option is
|
being used.
|
</p>
|
</dd>
|
<dt><code>-Wstrict-selector-match <span class="roman">(Objective-C and Objective-C++ only)</span></code></dt>
|
<dd><a name="index-Wstrict_002dselector_002dmatch"></a>
|
<a name="index-Wno_002dstrict_002dselector_002dmatch"></a>
|
<p>Warn if multiple methods with differing argument and/or return types are
|
found for a given selector when attempting to send a message using this
|
selector to a receiver of type <code>id</code> or <code>Class</code>. When this flag
|
is off (which is the default behavior), the compiler omits such warnings
|
if any differences found are confined to types that share the same size
|
and alignment.
|
</p>
|
</dd>
|
<dt><code>-Wundeclared-selector <span class="roman">(Objective-C and Objective-C++ only)</span></code></dt>
|
<dd><a name="index-Wundeclared_002dselector"></a>
|
<a name="index-Wno_002dundeclared_002dselector"></a>
|
<p>Warn if a <code>@selector(…)</code> expression referring to an
|
undeclared selector is found. A selector is considered undeclared if no
|
method with that name has been declared before the
|
<code>@selector(…)</code> expression, either explicitly in an
|
<code>@interface</code> or <code>@protocol</code> declaration, or implicitly in
|
an <code>@implementation</code> section. This option always performs its
|
checks as soon as a <code>@selector(…)</code> expression is found,
|
while <samp>-Wselector</samp> only performs its checks in the final stage of
|
compilation. This also enforces the coding style convention
|
that methods and selectors must be declared before being used.
|
</p>
|
</dd>
|
<dt><code>-print-objc-runtime-info</code></dt>
|
<dd><a name="index-print_002dobjc_002druntime_002dinfo"></a>
|
<p>Generate C header describing the largest structure that is passed by
|
value, if any.
|
</p>
|
</dd>
|
</dl>
|
|
<hr>
|
<div class="header">
|
<p>
|
Next: <a href="Diagnostic-Message-Formatting-Options.html#Diagnostic-Message-Formatting-Options" accesskey="n" rel="next">Diagnostic Message Formatting Options</a>, Previous: <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options" accesskey="p" rel="prev">C++ Dialect Options</a>, Up: <a href="Invoking-GCC.html#Invoking-GCC" accesskey="u" rel="up">Invoking GCC</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
|
</div>
|
|
|
|
</body>
|
</html>
|