?? objective-c-dialect-options.html
字號(hào):
<html lang="en"><head><title>Using the GNU Compiler Collection (GCC)</title><meta http-equiv="Content-Type" content="text/html"><meta name="description" content="Using the GNU Compiler Collection (GCC)"><meta name="generator" content="makeinfo 4.6"><!--Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded in the section entitled "GNU Free Documentation License". <p>(a) The FSF's Front-Cover Text is: <p>A GNU Manual <p>(b) The FSF's Back-Cover Text is: <p>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.--><meta http-equiv="Content-Style-Type" content="text/css"><style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller }--></style></head><body><div class="node"><p>Node: <a name="Objective-C%20Dialect%20Options">Objective-C Dialect Options</a>,Next: <a rel="next" accesskey="n" href="Language-Independent-Options.html#Language%20Independent%20Options">Language Independent Options</a>,Previous: <a rel="previous" accesskey="p" href="C---Dialect-Options.html#C++%20Dialect%20Options">C++ Dialect Options</a>,Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a><hr><br></div><h3 class="section">Options Controlling Objective-C Dialect</h3><p>(NOTE: This manual does not describe the Objective-C language itself. See<a href="http://gcc.gnu.org/readings.html">http://gcc.gnu.org/readings.html</a> for references.) <p>This section describes the command-line options that are only meaningfulfor Objective-C programs, but you can also use most of the GNU compileroptions regardless of what language your program is in. For example,you might compile a file <code>some_class.m</code> like this:<pre class="smallexample"> gcc -g -fgnu-runtime -O -c some_class.m </pre><p>In this example, <code>-fgnu-runtime</code> is an option meant only forObjective-C programs; you can use the other options with any languagesupported by GCC. <p>Here is a list of options that are <em>only</em> for compiling Objective-Cprograms: <dl><dt><code>-fconstant-string-class=</code><var>class-name</var><code></code> <dd>Use <var>class-name</var> as the name of the class to instantiate for eachliteral string specified with the syntax <code>@"..."</code>. The defaultclass 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<code>-fconstant-cfstrings</code> option, if also present, will override the<code>-fconstant-string-class</code> setting and cause <code>@"..."</code> literalsto be laid out as constant CoreFoundation strings. <br><dt><code>-fgnu-runtime</code> <dd>Generate object code compatible with the standard GNU Objective-Cruntime. This is the default for most types of systems. <br><dt><code>-fnext-runtime</code> <dd>Generate output compatible with the NeXT runtime. This is the defaultfor NeXT-based systems, including Darwin and Mac OS X. The macro<code>__NEXT_RUNTIME__</code> is predefined if (and only if) this option isused. <br><dt><code>-fno-nil-receivers</code> <dd>Assume that all Objective-C message dispatches (e.g.,<code>[receiver message:arg]</code>) in this translation unit ensure that the receiveris not <code>nil</code>. This allows for more efficient entry points in the runtime to beused. Currently, this option is only available in conjunction withthe NeXT runtime on Mac OS X 10.3 and later. <br><dt><code>-fobjc-exceptions</code> <dd>Enable syntactic support for structured exception handling in Objective-C,similar to what is offered by C++ and Java. Currently, this option is onlyavailable in conjunction with the NeXT runtime on Mac OS X 10.3 and later. <pre class="smallexample"> @try { ... @throw expr; ... } @catch (AnObjCClass *exc) { ... @throw expr; ... @throw; ... } @catch (AnotherClass *exc) { ... } @catch (id allOthers) { ... } @finally { ... @throw expr; ... } </pre> <p>The <code>@throw</code> statement may appear anywhere in an Objective-C orObjective-C++ program; when used inside of a <code>@catch</code> block, the<code>@throw</code> may appear without an argument (as shown above), in which casethe object caught by the <code>@catch</code> will be rethrown. <p>Note that only (pointers to) Objective-C objects may be thrown andcaught using this scheme. When an object is thrown, it will be caughtby the nearest <code>@catch</code> clause capable of handling objects of that type,analogously to how <code>catch</code> blocks work in C++ and Java. A<code>@catch(id ...)</code> clause (as shown above) may also be provided to catchany and all Objective-C exceptions not caught by previous <code>@catch</code>clauses (if any). <p>The <code>@finally</code> clause, if present, will be executed upon exit from theimmediately preceding <code>@try ... @catch</code> section. This will happenregardless of whether any exceptions are thrown, caught or rethrowninside the <code>@try ... @catch</code> section, analogously to the behaviorof the <code>finally</code> clause in Java. <p>There are several caveats to using the new exception mechanism: <ul><li>Although currently designed to be binary compatible with <code>NS_HANDLER</code>-styleidioms provided by the <code>NSException</code> class, the newexceptions can only be used on Mac OS X 10.3 (Panther) and latersystems, due to additional functionality needed in the (NeXT) Objective-Cruntime. <li>As mentioned above, the new exceptions do not support handlingtypes other than Objective-C objects. Furthermore, when used fromObjective-C++, the Objective-C exception model does not interoperate with C++exceptions at this time. This means you cannot <code>@throw</code> an exceptionfrom Objective-C and <code>catch</code> it in C++, or vice versa(i.e., <code>throw ... @catch</code>). </ul> <p>The <code>-fobjc-exceptions</code> switch also enables the use of synchronizationblocks for thread-safe execution: <pre class="smallexample"> @synchronized (ObjCClass *guard) { ... } </pre> <p>Upon entering the <code>@synchronized</code> block, a thread of execution shallfirst check whether a lock has been placed on the corresponding <code>guard</code>object by another thread. If it has, the current thread shall wait untilthe other thread relinquishes its lock. Once <code>guard</code> becomes available,the current thread will place its own lock on it, execute the code contained inthe <code>@synchronized</code> block, and finally relinquish the lock (therebymaking <code>guard</code> available to other threads). <p>Unlike Java, Objective-C does not allow for entire methods to be marked<code>@synchronized</code>. Note that throwing exceptions out of<code>@synchronized</code> blocks is allowed, and will cause the guarding objectto be unlocked properly. <br><dt><code>-freplace-objc-classes</code> <dd>Emit a special marker instructing <code>ld(1)</code> not to statically link inthe resulting object file, and allow <code>dyld(1)</code> to load it in atrun time instead. This is used in conjunction with the Fix-and-Continuedebugging mode, where the object file in question may be recompiled anddynamically reloaded in the course of program execution, without the needto restart the program itself. Currently, Fix-and-Continue functionalityis only available in conjunction with the NeXT runtime on Mac OS X 10.3and later. <br><dt><code>-fzero-link</code> <dd>When compiling for the NeXT runtime, the compiler ordinarily replaces callsto <code>objc_getClass("...")</code> (when the name of the class is known atcompile time) with static class references that get initialized at load time,which improves run-time performance. Specifying the <code>-fzero-link</code> flagsuppresses this behavior and causes calls to <code>objc_getClass("...")</code>to be retained. This is useful in Zero-Link debugging mode, since it allowsfor individual class implementations to be modified during program execution. <br><dt><code>-gen-decls</code> <dd>Dump interface declarations for all classes seen in the source file to afile named <code></code><var>sourcename</var><code>.decl</code>. <br><dt><code>-Wno-protocol</code> <dd>If a class is declared to implement a protocol, a warning is issued forevery method in the protocol that is not implemented by the class. Thedefault behavior is to issue a warning for every method not explicitlyimplemented in the class, even if a method implementation is inheritedfrom the superclass. If you use the <code>-Wno-protocol</code> option, thenmethods inherited from the superclass are considered to be implemented,and no warning is issued for them. <br><dt><code>-Wselector</code> <dd>Warn if multiple methods of different types for the same selector arefound during compilation. The check is performed on the list of methodsin the final stage of compilation. Additionally, a check is performedfor each selector appearing in a <code>@selector(...)</code>expression, and a corresponding method for that selector has been foundduring compilation. Because these checks scan the method table only atthe end of compilation, these warnings are not produced if the finalstage of compilation is not reached, for example because an error isfound during compilation, or because the <code>-fsyntax-only</code> option isbeing used. <br><dt><code>-Wundeclared-selector</code> <dd>Warn if a <code>@selector(...)</code> expression referring to anundeclared selector is found. A selector is considered undeclared if nomethod 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 inan <code>@implementation</code> section. This option always performs itschecks as soon as a <code>@selector(...)</code> expression is found,while <code>-Wselector</code> only performs its checks in the final stage ofcompilation. This also enforces the coding style conventionthat methods and selectors must be declared before being used. <br><dt><code>-print-objc-runtime-info</code> <dd>Generate C header describing the largest structure that is passed byvalue, if any. </dl> </body></html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -