Thomas Mitta was asking about using C++ with the GNU package earlier on
the dev list; it *can* be done, I should know, I started my Palm
development doing that (and still at it! :). Talk about shooting 
myself in the foot, though... :)

Yes, the default_new_handler is screwed; what you need to do is
overload the new operator with appropriate Palm OS allocation calls 
in the classes you wish to new and delete.

Here's what I did;

#if defined(PALMOS)

        // override standard memory manager under PalmOS
        inline void* operator new (size_t s) { return MemPtrNew (s); }
        inline void* operator new[] (size_t s) { return MemPtrNew (s); }

        inline void operator delete (void* p)  { MemPtrFree (p); }
        inline void operator delete[] (void* p)  { MemPtrFree (p); }

#endif

Obviously, appropriate error checks can be added to the previous, and by
using memory handles instead of pointers it should be safer still.

Apart from this, I have not run into problems with C++ and PalmOS.

Have a happy C++!


Jouni
--
Jouni Mannonen
SurRender3D.com

Reply via email to