Symbian3/SDK/Source/GUID-DF1B3C55-2CFC-49C8-88A2-D10925ECAC3E.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     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-DF1B3C55-2CFC-49C8-88A2-D10925ECAC3E" xml:lang="en"><title>Known
       
    13 Issues</title><shortdesc/><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <section id="GUID-EB71EFD6-DBEC-4C0F-B9E5-3370204AE18A"><title>ARM RVCT compiler
       
    15 issues with STLport</title><p>Due to a defect in the ARM RVCT compiler versions
       
    16 2.2, 3.1 and 4.0, building STLport v4 or STLport-based applications, creates
       
    17 some invalid export entries in DEF files. To workaround this issue, perform
       
    18 the following steps:</p><ol>
       
    19 <li id="GUID-D5C91387-CF86-4D65-ACAF-05A5500DA090"><p>Use the GCCE compiler
       
    20 to generate the DEF file, if it is not available.</p></li>
       
    21 <li id="GUID-A0D36B39-ECEB-431A-80FD-6005542F4D7F"><p>Ignore the warnings
       
    22 generated by the ARM RVCT compiler.</p><note>When you ignore the warnings,
       
    23 do not freeze the invalid export entries in the DEF file using the ARM RVCT
       
    24 compiler.</note></li>
       
    25 </ol></section>
       
    26 <section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-8-1-11-1-1-9-1-6-1-3-2">       <title>Use
       
    27 of Global Destructor</title>       <p>Symbian does not invoke destructors
       
    28 of global objects upon program termination. For example, in the code below,
       
    29 the destructor <codeph>~foo()</codeph> is not called upon program termination.
       
    30 At the moment, it is advised not to perform any important operations using
       
    31 destructors.</p><codeblock xml:space="preserve">#include 
       
    32 using namespace std; 
       
    33 class foo
       
    34 {
       
    35 public:
       
    36 foo()
       
    37 {
       
    38 cout &lt;&lt;"Entering foo\n"; 
       
    39 }
       
    40 ~foo()
       
    41 {
       
    42 cout &lt;&lt;"Leaving foo\n";
       
    43 }
       
    44 };
       
    45 foo foo_bar; 
       
    46 int main(void)
       
    47 {
       
    48 return 0;
       
    49 }
       
    50 
       
    51 </codeblock>     </section>
       
    52 <section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-8-1-11-1-1-9-1-6-1-3-3">       <title>Issues
       
    53 with <codeph>new</codeph> operator</title>       <p>Throwing <codeph>bad_alloc</codeph> or
       
    54 any object from new on ARMV5 platfrom crashes. RVCT reports an exception when <codeph>new</codeph> throws <codeph>bad_alloc</codeph>.
       
    55 The problem occurs even if the user throws any object from within an overloaded
       
    56 operator <codeph>new</codeph>. The following new signatures are affected:</p><codeblock xml:space="preserve">void *operator new(unsigned int aSize);
       
    57 void *operator new[](unsigned int aSize);
       
    58 </codeblock><p>The following code snippet is an example that depicts the problem:</p><codeblock xml:space="preserve">class Dummy
       
    59 {
       
    60 }; 
       
    61 void *operator new(unsigned int aSize)
       
    62 {
       
    63 void* __y = malloc(aSize);
       
    64 // try to simulate bad alloc
       
    65 if (__y == 0)
       
    66 {
       
    67 throw Dummy(); //this will result in a crash
       
    68 }
       
    69 return __y;
       
    70 }
       
    71 </codeblock><p>To implement user owned overloaded version of new, the user
       
    72 must implement them as class specific. The other way this could be achieved
       
    73 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
       
    74 invoking it as:</p><codeblock xml:space="preserve">Myclass* my = new(S60) Myclass()</codeblock> 
       
    75    </section>
       
    76 <section id="GUID-DDE6596E-1A67-4219-8822-45A82C39DF0B-GENID-1-8-1-11-1-1-9-1-6-1-3-4">       <title>The <codeph>id</codeph> Member
       
    77 Issue</title>       <p>The <codeph>id</codeph> member variable of facet classes
       
    78 cannot be accessed directly, it has to be accessed via the <codeph>GetFacetLocaleId()</codeph> interface.</p><p>Following
       
    79 code snippet is an example that illustrates how to <codeph>uselocale::id</codeph> while
       
    80 writing an application on top of the Standard Template Library (STL). Declare
       
    81 a static method <codeph>GetFacetLocaleId()</codeph> instead of the member
       
    82 variable id when, defining a class <codeph>base_facet</codeph> inherited from <codeph>locale::facet</codeph> in
       
    83 a header file.</p><codeblock xml:space="preserve">//b_facet.h 
       
    84 class base_facet : public locale::facet 
       
    85 { 
       
    86 public: 
       
    87 static locale::id; 
       
    88 GetFacetLocaleId(); // in place of static locale::id
       
    89 id; 
       
    90 };
       
    91 </codeblock><p>In the source file define the method <codeph>GetFacetLocaleId()</codeph>. </p><codeblock xml:space="preserve">//b_facet.cpp
       
    92 locale::id base_facet_id; 
       
    93 locale::id&amp; base_facet::GetFacetLocaleId()
       
    94 { 
       
    95 return base_facet_id; 
       
    96 }
       
    97 </codeblock>     </section>
       
    98 <section id="GUID-0EBB7F0F-2C2D-4707-BD53-96DC40443CAF"><title>Interleaving
       
    99 Symbian and Standard C++ Code</title><p>The user must exercise caution while
       
   100 using <codeph>try</codeph> or <codeph>catch</codeph>, and <codeph>trap</codeph> while
       
   101 interleaving Symbian C++ and Standard C++ code. Adapter code is required to
       
   102 handover or suppress exception coming from the Standard C++ to Symbian C++
       
   103 code.</p><p>Following code snippet illustrates how to use the adaptor code.
       
   104 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()
       
   105 {
       
   106    class foo *p = new __foo__();
       
   107    p-&gt;bar();
       
   108    delete p;
       
   109 };
       
   110 </codeblock><p><b>DLLB - Standard C++ code</b></p><codeblock xml:space="preserve">class foo {
       
   111 public:
       
   112   foo(); //constructor
       
   113   bar(); // throw exception
       
   114 };
       
   115 </codeblock><p><b>DLLC - Adaptor code</b></p><codeblock xml:space="preserve">class __foo__ {
       
   116   foo *p;
       
   117 public:
       
   118   __foo__();
       
   119   bar();
       
   120 };
       
   121 
       
   122 void __foo__::__foo__()
       
   123 {
       
   124    int err = 0;
       
   125    try {
       
   126       p = new foo();
       
   127    } catch {
       
   128      err = some error
       
   129    }
       
   130    User::LeaveIfError(err);
       
   131 };
       
   132 void __foo__::bar()
       
   133 {
       
   134    int err = 0;
       
   135    try {
       
   136       p-&gt;bar();
       
   137    } catch {
       
   138      err = some error
       
   139    }
       
   140    User::LeaveIfError(err);
       
   141 };
       
   142 </codeblock></section>
       
   143 </conbody></concept>