week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-B661DFBC-9779-597D-A1DA-4FE085DAA61A" xml:lang="en"><title>CRT0
Libraries of STDLIB</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>This section explains the CRT0 libraries provided by STDLIB. </p>
<p>The following table lists the CRT0 libraries: </p>
<table id="GUID-D74087AE-6FCA-5C46-98AE-EAC4AE3B6867">
<tgroup cols="2"><colspec colname="col0"/><colspec colname="col1"/>
<thead>
<row>
<entry>Simple Mode (thread local mode)</entry>
</row>
</thead>
<tbody>
<row>
<entry><p> <codeph>ecrt0.lib</codeph> </p> </entry>
<entry><p>EABI Emulators Narrow <codeph>char main (int
argc, char *argv[], char *envp[])</codeph> </p> </entry>
</row>
<row>
<entry><p> <codeph>wecrt0.lib</codeph> </p> </entry>
<entry><p>EABI Emulators Wide <codeph>char main (int
argc, wchar_t *argv[], wchar_t *envp[])</codeph> </p> </entry>
</row>
<row>
<entry valign="bottom"><p><b>Complex Mode (multi threaded mode / POSIX server
mode)</b></p></entry>
<entry valign="bottom"/>
</row>
<row>
<entry><p> <codeph> mcrt0.lib</codeph> </p> </entry>
<entry><p>EABI Emulators Narrow <codeph>char main (int
argc, char *argv[], char *envp[]</codeph> </p> </entry>
</row>
<row>
<entry><p> <codeph>wcrt0.lib</codeph> </p> </entry>
<entry><p>Emulators Narrow <codeph>char main (int argc,
char *argv[], char *envp[])</codeph> with stdxxx redirection
to Win32 using RWin32Stream server </p> </entry>
</row>
<row>
<entry><p> <codeph>wmcrt0.lib</codeph> </p> </entry>
<entry><p>EABI Emulators Wide <codeph>char wmain (int
argc, wchar_t *argv[], wchar_t *envp[])</codeph> </p> </entry>
</row>
<row>
<entry><p> <codeph>wwcrt0.lib</codeph> </p> </entry>
<entry><p>Emulator Wide <codeph>char wmain (int argc,
wchar_t *argv[], wchar_t *envp[])</codeph> with stdxxx redirection
to Win32 using RWin32Stream server </p> </entry>
</row>
<row>
<entry valign="bottom"><p><b>Other</b></p></entry>
<entry valign="bottom"/>
</row>
<row>
<entry><p> <codeph>estw32.dll</codeph> </p> </entry>
<entry><p>Emulators: Provides the RWin32Stream server </p> </entry>
</row>
<row>
<entry><p> <codeph>redircli.dll</codeph> </p> </entry>
<entry><p>EABI Emulators: Provides application specific redirection
(for example, to Java RT or test applications). </p> </entry>
</row>
</tbody>
</tgroup>
</table>
<p>These static libraries provide the compiler runtime glue code that runs
from the Symbian <codeph>E32Main()</codeph> entry point for regular Symbian
executables into the standard C <codeph>main()</codeph> entry point. </p>
<p>These executables are considered to be C programs hosted in a Symbian executable
image. The glue code has a number of functions to perform, for example: </p>
<ul>
<li id="GUID-2692C4C1-78E3-5F5B-BA1F-53FCE4CC085C"><p>marshalling the process
command arguments in the types used by <codeph>main()</codeph> </p> </li>
<li id="GUID-822978FA-C8B4-5E01-A19A-F99306D31582"><p>initialising the C Standard
library context and mode of operation for example, calling <codeph>SpawnPosixServerThread()</codeph>. </p> </li>
</ul>
<section><title>ECRT0.lib and the cleanup stack</title> <p>A normal Symbian
platform executable provides an <codeph>E32Main()</codeph> function which
is called by the operating system to start the program. The file <filepath>ecrt0.lib</filepath> provides
an <codeph>E32Main()</codeph> function for programs which use STDLIB. This
function prepares the traditional <codeph>argc</codeph> and <codeph>argv</codeph> arguments,
and passes them to <codeph>main()</codeph>. </p> <p>For a simple example demonstrating
how to link to <filepath>ecrt0.lib</filepath>, see the description of the
project specification for "Hello World" in <xref href="GUID-F51062B0-90BB-5659-9F23-2FF25116D78A.dita">Porting</xref>.
The user of STDLIB need not use <filepath>ecrt0.lib</filepath>, and may provide
their own <codeph>E32Main()</codeph>. In this case, a <codeph>CTrapCleanup</codeph> pointer
should normally be provided. This pointer is required because although STDLIB
does not call Symbian platform functions which can leave, it uses few functions
which require a cleanup stack. Code in <filepath>ecrt0.lib</filepath> provides
such a cleanup stack ("<codeph>TheTrapCleanup</codeph> "), but programs which
do not link with <filepath>ecrt0.lib</filepath> must supply one directly. </p> <p>For
more details on the motivation behind Symbian's use of the cleanup stack,
see <xref href="GUID-61DEE78D-4E78-5367-BC8A-F99D3B4E9D5A.dita">Cleanup support</xref>. </p> <p> <b> NOTE</b>:
If the program is a UI application, that is, one that includes the following
code in one of the source files: </p> <codeblock id="GUID-D8C4F7A9-9755-58EC-BED9-0232259970BE" xml:space="preserve">GLDEF_C TInt E32Main()
{
return EikStart::RunApplication(NewApplication);
}</codeblock> <p>then, the <codeph>CTrapCleanup</codeph> pointer is provided
by the application framework. </p> </section>
</conbody><related-links>
<link href="GUID-F51062B0-90BB-5659-9F23-2FF25116D78A.dita"><linktext>Porting Tutorials</linktext>
</link>
<link href="GUID-61DEE78D-4E78-5367-BC8A-F99D3B4E9D5A.dita"><linktext>Cleanup support
guide</linktext></link>
</related-links></concept>