Symbian3/SDK/Source/GUID-DF1B3C55-2CFC-49C8-88A2-D10925ECAC3E.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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-DF1B3C55-2CFC-49C8-88A2-D10925ECAC3E" xml:lang="en"><title>Known
Issues</title><shortdesc/><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-EB71EFD6-DBEC-4C0F-B9E5-3370204AE18A"><title>ARM RVCT compiler
issues with STLport</title><p>Due to a defect in the ARM RVCT compiler versions
2.2, 3.1 and 4.0, building STLport v4 or STLport-based applications, creates
some invalid export entries in DEF files. To workaround this issue, perform
the following steps:</p><ol>
<li id="GUID-D5C91387-CF86-4D65-ACAF-05A5500DA090"><p>Use the GCCE compiler
to generate the DEF file, if it is not available.</p></li>
<li id="GUID-A0D36B39-ECEB-431A-80FD-6005542F4D7F"><p>Ignore the warnings
generated by the ARM RVCT compiler.</p><note>When you ignore the warnings,
do not freeze the invalid export entries in the DEF file using the ARM RVCT
compiler.</note></li>
</ol></section>
<section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-10-1-11-1-1-9-1-6-1-3-2">       <title>Use
of Global Destructor</title>       <p>Symbian does not invoke destructors
of global objects upon program termination. For example, in the code below,
the destructor <codeph>~foo()</codeph> is not called upon program termination.
At the moment, it is advised not to perform any important operations using
destructors.</p><codeblock xml:space="preserve">#include 
using namespace std; 
class foo
{
public:
foo()
{
cout &lt;&lt;"Entering foo\n"; 
}
~foo()
{
cout &lt;&lt;"Leaving foo\n";
}
};
foo foo_bar; 
int main(void)
{
return 0;
}

</codeblock>     </section>
<section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-10-1-11-1-1-9-1-6-1-3-3">       <title>Issues
with <codeph>new</codeph> operator</title>       <p>Throwing <codeph>bad_alloc</codeph> or
any object from new on ARMV5 platfrom crashes. RVCT reports an exception when <codeph>new</codeph> throws <codeph>bad_alloc</codeph>.
The problem occurs even if the user throws any object from within an overloaded
operator <codeph>new</codeph>. The following new signatures are affected:</p><codeblock xml:space="preserve">void *operator new(unsigned int aSize);
void *operator new[](unsigned int aSize);
</codeblock><p>The following code snippet is an example that depicts the problem:</p><codeblock xml:space="preserve">class Dummy
{
}; 
void *operator new(unsigned int aSize)
{
void* __y = malloc(aSize);
// try to simulate bad alloc
if (__y == 0)
{
throw Dummy(); //this will result in a crash
}
return __y;
}
</codeblock><p>To implement user owned overloaded version of new, the user
must implement them as class specific. The other way this could be achieved
is by defining new similar to:</p><codeblock xml:space="preserve">void* operator new(size_t s,newarg) throw (std::bad_alloc)</codeblock><p>and
invoking it as:</p><codeblock xml:space="preserve">Myclass* my = new(S60) Myclass()</codeblock> 
   </section>
<section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-10-1-11-1-1-9-1-6-1-3-4">       <title>The <codeph>id</codeph> Member
Issue</title>       <p>The <codeph>id</codeph> member variable of facet classes
cannot be accessed directly, it has to be accessed via the <codeph>GetFacetLocaleId()</codeph> interface.</p><p>Following
code snippet is an example that illustrates how to <codeph>uselocale::id</codeph> while
writing an application on top of the Standard Template Library (STL). Declare
a static method <codeph>GetFacetLocaleId()</codeph> instead of the member
variable id when, defining a class <codeph>base_facet</codeph> inherited from <codeph>locale::facet</codeph> in
a header file.</p><codeblock xml:space="preserve">//b_facet.h 
class base_facet : public locale::facet 
{ 
public: 
static locale::id; 
GetFacetLocaleId(); // in place of static locale::id
id; 
};
</codeblock><p>In the source file define the method <codeph>GetFacetLocaleId()</codeph>. </p><codeblock xml:space="preserve">//b_facet.cpp
locale::id base_facet_id; 
locale::id&amp; base_facet::GetFacetLocaleId()
{ 
return base_facet_id; 
}
</codeblock>     </section>
<section id="GUID-0EBB7F0F-2C2D-4707-BD53-96DC40443CAF"><title>Interleaving
Symbian and Standard C++ Code</title><p>The user must exercise caution while
using <codeph>try</codeph> or <codeph>catch</codeph>, and <codeph>trap</codeph> while
interleaving Symbian C++ and Standard C++ code. Adapter code is required to
handover or suppress exception coming from the Standard C++ to Symbian C++
code.</p><p>Following code snippet illustrates how to use the adaptor code.
Adaptor code can be a part of DLLA.  </p><p><b>DLL A - Symbian C++ code</b></p><codeblock xml:space="preserve">void CDoIt::Doit()
{
   class foo *p = new __foo__();
   p-&gt;bar();
   delete p;
};
</codeblock><p><b>DLLB - Standard C++ code</b></p><codeblock xml:space="preserve">class foo {
public:
  foo(); //constructor
  bar(); // throw exception
};
</codeblock><p><b>DLLC - Adaptor code</b></p><codeblock xml:space="preserve">class __foo__ {
  foo *p;
public:
  __foo__();
  bar();
};

void __foo__::__foo__()
{
   int err = 0;
   try {
      p = new foo();
   } catch {
     err = some error
   }
   User::LeaveIfError(err);
};
void __foo__::bar()
{
   int err = 0;
   try {
      p-&gt;bar();
   } catch {
     err = some error
   }
   User::LeaveIfError(err);
};
</codeblock></section>
</conbody></concept>