10 <!DOCTYPE concept |
10 <!DOCTYPE concept |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
12 <concept id="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46" xml:lang="en"><title>Possible |
12 <concept id="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46" xml:lang="en"><title>Possible |
13 Problems</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
13 Problems</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
14 <p>This section describes the possible problems that you may encounter when |
14 <p>This section describes the possible problems that you may encounter when |
15 you develop applications or libraries on Symbian platform based on Standard |
15 you develop applications or libraries on the Symbian platform |
16 C++. These problems can occur in the following scenarios: </p> |
16 based on Standard C++. These problems can occur in the following scenarios: </p> |
17 <ul> |
17 <ul> |
18 <li id="GUID-A3F0DCD7-CA38-5405-B01D-1E3B3F75B67D"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-39350E32-26C2-5440-B221-10EE693CCF18">Use of operator new</xref> </p> </li> |
18 <li id="GUID-A3F0DCD7-CA38-5405-B01D-1E3B3F75B67D"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-39350E32-26C2-5440-B221-10EE693CCF18">Use of operator new</xref> </p> </li> |
19 <li id="GUID-9B185254-36B9-58F7-888D-8198EAD77769"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-A85386B3-3E37-5303-8FBF-211551D5CB71">Use of one definition rule</xref> </p> </li> |
19 <li id="GUID-9B185254-36B9-58F7-888D-8198EAD77769"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-A85386B3-3E37-5303-8FBF-211551D5CB71">Use of one definition rule</xref> </p> </li> |
20 <li id="GUID-01A440D6-7E35-5F4E-8E1E-F5877F3967F2"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-6CE49D59-46BB-5145-B346-6FD3EA8BC011"> Standard C++ calling Symbian C++ functions </xref> </p> </li> |
20 <li id="GUID-01A440D6-7E35-5F4E-8E1E-F5877F3967F2"><p><xref href="GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46.dita#GUID-AF2CE612-F12E-5A18-81A5-C303992D2D46/GUID-6CE49D59-46BB-5145-B346-6FD3EA8BC011"> Standard C++ calling Symbian C++ functions </xref> </p> </li> |
21 </ul> |
21 </ul> |
42 <section id="GUID-A85386B3-3E37-5303-8FBF-211551D5CB71"><title>Use of one |
42 <section id="GUID-A85386B3-3E37-5303-8FBF-211551D5CB71"><title>Use of one |
43 definition rule</title> <p>As per Standard C++, one definition rule (ODR) |
43 definition rule</title> <p>As per Standard C++, one definition rule (ODR) |
44 says that there must be only one definition of a symbol in a program. But |
44 says that there must be only one definition of a symbol in a program. But |
45 to be able to maintain a single definition in a program, symbol pre-emption |
45 to be able to maintain a single definition in a program, symbol pre-emption |
46 must be possible. This functionality is not supported on the DLL model of |
46 must be possible. This functionality is not supported on the DLL model of |
47 Symbian platform. </p> <p><b>Example</b> </p> <p>The following example illustrates |
47 the Symbian platform. </p> <p><b>Example</b> </p> <p>The following example |
48 the problem with the use of one definition rule: </p> <codeblock id="GUID-FB9FBAAD-8CB8-5EAB-BA25-18A92822CF8E" xml:space="preserve">//MySingleton.h |
48 illustrates the problem with the use of one definition rule: </p> <codeblock id="GUID-FB9FBAAD-8CB8-5EAB-BA25-18A92822CF8E" xml:space="preserve">//MySingleton.h |
49 template <class T> |
49 template <class T> |
50 class MySingleton |
50 class MySingleton |
51 { |
51 { |
52 public: |
52 public: |
53 static T& GetInstance() |
53 static T& GetInstance() |
83 } |
83 } |
84 int E32Main() |
84 int E32Main() |
85 { |
85 { |
86 printf("%d\n", Baz()); |
86 printf("%d\n", Baz()); |
87 }</codeblock> <p>This example must have displayed the output as <b>1, |
87 }</codeblock> <p>This example must have displayed the output as <b>1, |
88 2</b>. But on Symbian platform, it displays <b>1,1</b>. </p> <p>The problem |
88 2</b>. But on the Symbian platform, it displays <b>1,1</b>. </p> <p>The problem |
89 here is Symbian platform's DLL model. In particular Symbian platform does |
89 here is, the Symbian platform's DLL model. In particular, the Symbian platform |
90 not support symbol pre-emption. In Symbian platform <codeph>static T * aT</codeph> gets |
90 does not support symbol pre-emption. <codeph>static T * aT</codeph> gets allocated |
91 allocated in each DLL in which <codeph>X::GetInstance</codeph> is invoked. |
91 in each DLL in which <codeph>X::GetInstance</codeph> is invoked. Here the |
92 Here the problem arises because Symbian platform cannot redirect the references |
92 problem arises because the Symbian platform cannot redirect the references |
93 in distinct DLLs to a single unique location as required by the ODR. </p> </section> |
93 in distinct DLLs to a single unique location as required by the ODR. </p> </section> |
94 <section id="GUID-6CE49D59-46BB-5145-B346-6FD3EA8BC011"><title>Standard C++ |
94 <section id="GUID-6CE49D59-46BB-5145-B346-6FD3EA8BC011"><title>Standard C++ |
95 calling Symbian C++ functions</title> <p>The following example illustrates |
95 calling Symbian C++ functions</title> <p>The following example illustrates |
96 the nature of one of the problems associated with achieving <i>seamless</i> integration |
96 the nature of one of the problems associated with achieving <i>seamless</i> integration |
97 of Standard C++ with Symbian C++. Here <i>seamless</i> means: without the |
97 of Standard C++ with Symbian C++. Here <i>seamless</i> means: without the |
98 manual introduction of additional harness or barrier code to effect the integration. </p> <p> <codeph>SymbianCallerLC</codeph> calls |
98 manual introduction of additional harness or barrier code to effect the integration. </p> <p> <codeph>SymbianCallerLC</codeph> calls |
99 two different functions: </p> <ul> |
99 two different functions: </p> <ul> |
100 <li id="GUID-CC89E765-AF86-5300-BB76-F84DCF9E3910"><p>one which expects standard |
100 <li id="GUID-CC89E765-AF86-5300-BB76-F84DCF9E3910"><p>one which expects standard |
101 C++ semantics (<codeph>CppCallee</codeph>), and </p> </li> |
101 C++ semantics (<codeph>CppCallee</codeph>), and </p> </li> |
102 <li id="GUID-2E9D21A4-8FD3-5DC9-A264-7E7FEA05F4A9"><p>another which expects |
102 <li id="GUID-2E9D21A4-8FD3-5DC9-A264-7E7FEA05F4A9"><p>another which expects |
103 Symbian platform semantics (<codeph>GetAK1LC</codeph>). </p> </li> |
103 the Symbian platform semantics (<codeph>GetAK1LC</codeph>). </p> </li> |
104 </ul> <p> <codeph>SymbianCallerLC</codeph> itself belongs to the Symbian C++ |
104 </ul> <p> <codeph>SymbianCallerLC</codeph> itself belongs to the Symbian C++ |
105 world since it participates in the LC convention (it imposes a contract on |
105 world since it participates in the LC convention (it imposes a contract on |
106 its caller with respect to the object that it returns). </p> <codeblock id="GUID-D88FA0A6-1107-570D-B79A-30EA10E4AB0C" xml:space="preserve">K1 * SymbianCallerLC() |
106 its caller with respect to the object that it returns). </p> <codeblock id="GUID-D88FA0A6-1107-570D-B79A-30EA10E4AB0C" xml:space="preserve">K1 * SymbianCallerLC() |
107 { |
107 { |
108 K1 * aK1 = GetAK1LC(); |
108 K1 * aK1 = GetAK1LC(); |
154 <link href="GUID-D6BEAF0D-844D-51F4-8DB7-FB1D60E17FE3.dita"><linktext>Copyright |
154 <link href="GUID-D6BEAF0D-844D-51F4-8DB7-FB1D60E17FE3.dita"><linktext>Copyright |
155 Acknowledgments for Standard C++ (STLport)</linktext></link> |
155 Acknowledgments for Standard C++ (STLport)</linktext></link> |
156 <link href="GUID-F7FEB759-E64D-5B6D-9017-C5E982E4FC16.dita"><linktext>Standard |
156 <link href="GUID-F7FEB759-E64D-5B6D-9017-C5E982E4FC16.dita"><linktext>Standard |
157 C++ Library Overview</linktext></link> |
157 C++ Library Overview</linktext></link> |
158 <link href="GUID-2CCD1748-9EDE-5383-9941-A3051E06F3E2.dita"><linktext>Standard |
158 <link href="GUID-2CCD1748-9EDE-5383-9941-A3051E06F3E2.dita"><linktext>Standard |
159 C++ Support on Symbian Platform</linktext></link> |
159 C++ Support on the Symbian Platform</linktext></link> |
160 <link href="GUID-1ACD01D1-2055-581A-9478-2C0D7D1CF9E6.dita"><linktext>Use Cases |
160 <link href="GUID-1ACD01D1-2055-581A-9478-2C0D7D1CF9E6.dita"><linktext>Use Cases |
161 for Writing Standard C++ Code</linktext></link> |
161 for Writing Standard C++ Code</linktext></link> |
162 <link href="GUID-E331B72B-84AF-558A-9B8F-73E5E50B58C7.dita"><linktext>Building |
162 <link href="GUID-E331B72B-84AF-558A-9B8F-73E5E50B58C7.dita"><linktext>Building |
163 a Standard C++ Application or Library</linktext></link> |
163 a Standard C++ Application or Library</linktext></link> |
164 <link href="GUID-D32E52C9-F05C-5F1E-8B49-243D555C353C.dita"><linktext>Known Issues</linktext> |
164 <link href="GUID-D32E52C9-F05C-5F1E-8B49-243D555C353C.dita"><linktext>Known Issues</linktext> |