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:
Symbian does not invoke destructors
of global objects upon program termination. For example, in the code below,
the destructor ~foo()
is not called upon program termination.
At the moment, it is advised not to perform any important operations using
destructors.
#include using namespace std; class foo { public: foo() { cout <<"Entering foo\n"; } ~foo() { cout <<"Leaving foo\n"; } }; foo foo_bar; int main(void) { return 0; }
new
operatorThrowing bad_alloc
or
any object from new on ARMV5 platfrom crashes. RVCT reports an exception when new
throws bad_alloc
.
The problem occurs even if the user throws any object from within an overloaded
operator new
. The following new signatures are affected:
void *operator new(unsigned int aSize); void *operator new[](unsigned int aSize);
The following code snippet is an example that depicts the problem:
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; }
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:
void* operator new(size_t s,newarg) throw (std::bad_alloc)
and invoking it as:
Myclass* my = new(S60) Myclass()
id
Member
IssueThe id
member variable of facet classes
cannot be accessed directly, it has to be accessed via the GetFacetLocaleId()
interface.
Following
code snippet is an example that illustrates how to uselocale::id
while
writing an application on top of the Standard Template Library (STL). Declare
a static method GetFacetLocaleId()
instead of the member
variable id when, defining a class base_facet
inherited from locale::facet
in
a header file.
//b_facet.h class base_facet : public locale::facet { public: static locale::id; GetFacetLocaleId(); // in place of static locale::id id; };
In the source file define the method GetFacetLocaleId()
.
//b_facet.cpp locale::id base_facet_id; locale::id& base_facet::GetFacetLocaleId() { return base_facet_id; }
The user must exercise caution while
using try
or catch
, and trap
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.
Following code snippet illustrates how to use the adaptor code. Adaptor code can be a part of DLLA.
DLL A - Symbian C++ code
void CDoIt::Doit() { class foo *p = new __foo__(); p->bar(); delete p; };
DLLB - Standard C++ code
class foo { public: foo(); //constructor bar(); // throw exception };
DLLC - Adaptor code
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->bar(); } catch { err = some error } User::LeaveIfError(err); };