• 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>What you can and what you cannot do in +load - 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="Executing-code-before-main.html#Executing-code-before-main" title="Executing code before main">
9<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
10<!--
11Copyright (C) 1988-2013 Free Software Foundation, Inc.
12
13Permission is granted to copy, distribute and/or modify this document
14under the terms of the GNU Free Documentation License, Version 1.3 or
15any later version published by the Free Software Foundation; with the
16Invariant Sections being ``Funding Free Software'', the Front-Cover
17Texts being (a) (see below), and with the Back-Cover Texts being (b)
18(see below).  A copy of the license is included in the section entitled
19``GNU Free Documentation License''.
20
21(a) The FSF's Front-Cover Text is:
22
23     A GNU Manual
24
25(b) The FSF's Back-Cover Text is:
26
27     You have freedom to copy and modify this GNU Manual, like GNU
28     software.  Copies published by the Free Software Foundation raise
29     funds for GNU development.-->
30<meta http-equiv="Content-Style-Type" content="text/css">
31<style type="text/css"><!--
32  pre.display { font-family:inherit }
33  pre.format  { font-family:inherit }
34  pre.smalldisplay { font-family:inherit; font-size:smaller }
35  pre.smallformat  { font-family:inherit; font-size:smaller }
36  pre.smallexample { font-size:smaller }
37  pre.smalllisp    { font-size:smaller }
38  span.sc    { font-variant:small-caps }
39  span.roman { font-family:serif; font-weight:normal; } 
40  span.sansserif { font-family:sans-serif; font-weight:normal; } 
41--></style>
42<link rel="stylesheet" type="text/css" href="../cs.css">
43</head>
44<body>
45<div class="node">
46<a name="What-you-can-and-what-you-cannot-do-in-+load"></a>
47<a name="What-you-can-and-what-you-cannot-do-in-_002bload"></a>
48<p>
49Up:&nbsp;<a rel="up" accesskey="u" href="Executing-code-before-main.html#Executing-code-before-main">Executing code before main</a>
50<hr>
51</div>
52
53<h4 class="subsection">8.2.1 What you can and what you cannot do in <code>+load</code></h4>
54
55<p><code>+load</code> is to be used only as a last resort.  Because it is
56executed very early, most of the Objective-C runtime machinery will
57not be ready when <code>+load</code> is executed; hence <code>+load</code> works
58best for executing C code that is independent on the Objective-C
59runtime.
60
61 <p>The <code>+load</code> implementation in the GNU runtime guarantees you the
62following things:
63
64     <ul>
65<li>you can write whatever C code you like;
66
67     <li>you can allocate and send messages to objects whose class is implemented
68in the same file;
69
70     <li>the <code>+load</code> implementation of all super classes of a class are
71executed before the <code>+load</code> of that class is executed;
72
73     <li>the <code>+load</code> implementation of a class is executed before the
74<code>+load</code> implementation of any category.
75
76 </ul>
77
78 <p>In particular, the following things, even if they can work in a
79particular case, are not guaranteed:
80
81     <ul>
82<li>allocation of or sending messages to arbitrary objects;
83
84     <li>allocation of or sending messages to objects whose classes have a
85category implemented in the same file;
86
87     <li>sending messages to Objective-C constant strings (<code>@"this is a
88constant string"</code>);
89
90 </ul>
91
92 <p>You should make no assumptions about receiving <code>+load</code> in sibling
93classes when you write <code>+load</code> of a class.  The order in which
94sibling classes receive <code>+load</code> is not guaranteed.
95
96 <p>The order in which <code>+load</code> and <code>+initialize</code> are called could
97be problematic if this matters.  If you don't allocate objects inside
98<code>+load</code>, it is guaranteed that <code>+load</code> is called before
99<code>+initialize</code>.  If you create an object inside <code>+load</code> the
100<code>+initialize</code> method of object's class is invoked even if
101<code>+load</code> was not invoked.  Note if you explicitly call <code>+load</code>
102on a class, <code>+initialize</code> will be called first.  To avoid possible
103problems try to implement only one of these methods.
104
105 <p>The <code>+load</code> method is also invoked when a bundle is dynamically
106loaded into your running program.  This happens automatically without any
107intervening operation from you.  When you write bundles and you need to
108write <code>+load</code> you can safely create and send messages to objects whose
109classes already exist in the running program.  The same restrictions as
110above apply to classes defined in bundle.
111
112 </body></html>
113
114