Yes you can you classes (C++) in shared libraries, with some limitations...
You need to provide an operator new() & operator delete() functions (See
below)
You can not make use of any global or static data, (static functions are
alowwed, but data members are not). Nor can you use exceptions or
virtual functions, as CW stores the data for thease in the global memory
(which the libray hasn't got)
void * operator new(unsigned long size)
{
void* RetVal = NULL;
if (size)
RetVal = MemPtrNew(size);
return RetVal;
}
void operator delete(void *ptr)
{
if (ptr) MemPtrFree(ptr);
}
zhaoweillhch wrote:
I create a shared library project.In OnlineProtect.cpp file I use a class
object.And I use Metrowerks CodeWarrior Version 9.3,I meet a compile error.The
error is:
Link Error:OnlineProtect.cpp : 'operator delete(void *)' referenced from
'aTest::~aTest()' is undefined.
The class aTest is:
class aTest
{
public:
aTest() {};
~aTest(){};
void SetValue(UInt8 value) { };
UInt8 GetValue() { return 1;};
public:
}
The function is:
void TestClass()
{
aTest aa;
aa.SetValue(2);
}
I need your help, thanks!
--
For information on using the ACCESS Developer Forums, or to unsubscribe, please
see http://www.access-company.com/developers/forums/