|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-B661DFBC-9779-597D-A1DA-4FE085DAA61A" xml:lang="en"><title>CRT0 |
|
13 Libraries of STDLIB</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <p>This section explains the CRT0 libraries provided by STDLIB. </p> |
|
15 <p>The following table lists the CRT0 libraries: </p> |
|
16 <table id="GUID-D74087AE-6FCA-5C46-98AE-EAC4AE3B6867"> |
|
17 <tgroup cols="2"><colspec colname="col0"/><colspec colname="col1"/> |
|
18 <thead> |
|
19 <row> |
|
20 <entry>Simple Mode (thread local mode)</entry> |
|
21 </row> |
|
22 </thead> |
|
23 <tbody> |
|
24 <row> |
|
25 <entry><p> <codeph>ecrt0.lib</codeph> </p> </entry> |
|
26 <entry><p>EABI Emulators Narrow <codeph>char main (int |
|
27 argc, char *argv[], char *envp[])</codeph> </p> </entry> |
|
28 </row> |
|
29 <row> |
|
30 <entry><p> <codeph>wecrt0.lib</codeph> </p> </entry> |
|
31 <entry><p>EABI Emulators Wide <codeph>char main (int |
|
32 argc, wchar_t *argv[], wchar_t *envp[])</codeph> </p> </entry> |
|
33 </row> |
|
34 <row> |
|
35 <entry valign="bottom"><p><b>Complex Mode (multi threaded mode / POSIX server |
|
36 mode)</b></p></entry> |
|
37 <entry valign="bottom"/> |
|
38 </row> |
|
39 <row> |
|
40 <entry><p> <codeph> mcrt0.lib</codeph> </p> </entry> |
|
41 <entry><p>EABI Emulators Narrow <codeph>char main (int |
|
42 argc, char *argv[], char *envp[]</codeph> </p> </entry> |
|
43 </row> |
|
44 <row> |
|
45 <entry><p> <codeph>wcrt0.lib</codeph> </p> </entry> |
|
46 <entry><p>Emulators Narrow <codeph>char main (int argc, |
|
47 char *argv[], char *envp[])</codeph> with stdxxx redirection |
|
48 to Win32 using RWin32Stream server </p> </entry> |
|
49 </row> |
|
50 <row> |
|
51 <entry><p> <codeph>wmcrt0.lib</codeph> </p> </entry> |
|
52 <entry><p>EABI Emulators Wide <codeph>char wmain (int |
|
53 argc, wchar_t *argv[], wchar_t *envp[])</codeph> </p> </entry> |
|
54 </row> |
|
55 <row> |
|
56 <entry><p> <codeph>wwcrt0.lib</codeph> </p> </entry> |
|
57 <entry><p>Emulator Wide <codeph>char wmain (int argc, |
|
58 wchar_t *argv[], wchar_t *envp[])</codeph> with stdxxx redirection |
|
59 to Win32 using RWin32Stream server </p> </entry> |
|
60 </row> |
|
61 <row> |
|
62 <entry valign="bottom"><p><b>Other</b></p></entry> |
|
63 <entry valign="bottom"/> |
|
64 </row> |
|
65 <row> |
|
66 <entry><p> <codeph>estw32.dll</codeph> </p> </entry> |
|
67 <entry><p>Emulators: Provides the RWin32Stream server </p> </entry> |
|
68 </row> |
|
69 <row> |
|
70 <entry><p> <codeph>redircli.dll</codeph> </p> </entry> |
|
71 <entry><p>EABI Emulators: Provides application specific redirection |
|
72 (for example, to Java RT or test applications). </p> </entry> |
|
73 </row> |
|
74 </tbody> |
|
75 </tgroup> |
|
76 </table> |
|
77 <p>These static libraries provide the compiler runtime glue code that runs |
|
78 from the Symbian <codeph>E32Main()</codeph> entry point for regular Symbian |
|
79 executables into the standard C <codeph>main()</codeph> entry point. </p> |
|
80 <p>These executables are considered to be C programs hosted in a Symbian executable |
|
81 image. The glue code has a number of functions to perform, for example: </p> |
|
82 <ul> |
|
83 <li id="GUID-2692C4C1-78E3-5F5B-BA1F-53FCE4CC085C"><p>marshalling the process |
|
84 command arguments in the types used by <codeph>main()</codeph> </p> </li> |
|
85 <li id="GUID-822978FA-C8B4-5E01-A19A-F99306D31582"><p>initialising the C Standard |
|
86 library context and mode of operation for example, calling <codeph>SpawnPosixServerThread()</codeph>. </p> </li> |
|
87 </ul> |
|
88 <section><title>ECRT0.lib and the cleanup stack</title> <p>A normal Symbian |
|
89 platform executable provides an <codeph>E32Main()</codeph> function which |
|
90 is called by the operating system to start the program. The file <filepath>ecrt0.lib</filepath> provides |
|
91 an <codeph>E32Main()</codeph> function for programs which use STDLIB. This |
|
92 function prepares the traditional <codeph>argc</codeph> and <codeph>argv</codeph> arguments, |
|
93 and passes them to <codeph>main()</codeph>. </p> <p>For a simple example demonstrating |
|
94 how to link to <filepath>ecrt0.lib</filepath>, see the description of the |
|
95 project specification for "Hello World" in <xref href="GUID-F51062B0-90BB-5659-9F23-2FF25116D78A.dita">Porting</xref>. |
|
96 The user of STDLIB need not use <filepath>ecrt0.lib</filepath>, and may provide |
|
97 their own <codeph>E32Main()</codeph>. In this case, a <codeph>CTrapCleanup</codeph> pointer |
|
98 should normally be provided. This pointer is required because although STDLIB |
|
99 does not call Symbian platform functions which can leave, it uses few functions |
|
100 which require a cleanup stack. Code in <filepath>ecrt0.lib</filepath> provides |
|
101 such a cleanup stack ("<codeph>TheTrapCleanup</codeph> "), but programs which |
|
102 do not link with <filepath>ecrt0.lib</filepath> must supply one directly. </p> <p>For |
|
103 more details on the motivation behind Symbian's use of the cleanup stack, |
|
104 see <xref href="GUID-61DEE78D-4E78-5367-BC8A-F99D3B4E9D5A.dita">Cleanup support</xref>. </p> <p> <b> NOTE</b>: |
|
105 If the program is a UI application, that is, one that includes the following |
|
106 code in one of the source files: </p> <codeblock id="GUID-D8C4F7A9-9755-58EC-BED9-0232259970BE" xml:space="preserve">GLDEF_C TInt E32Main() |
|
107 { |
|
108 return EikStart::RunApplication(NewApplication); |
|
109 }</codeblock> <p>then, the <codeph>CTrapCleanup</codeph> pointer is provided |
|
110 by the application framework. </p> </section> |
|
111 </conbody><related-links> |
|
112 <link href="GUID-F51062B0-90BB-5659-9F23-2FF25116D78A.dita"><linktext>Porting Tutorials</linktext> |
|
113 </link> |
|
114 <link href="GUID-61DEE78D-4E78-5367-BC8A-F99D3B4E9D5A.dita"><linktext>Cleanup support |
|
115 guide</linktext></link> |
|
116 </related-links></concept> |