Oliver King-Smith wrote:
> I am using CW4.
>
> Here is a snippit of code
>
> class A{
> public:
> A() {}
> virtual ~A() {}
> };
>
> This is generating some global data. What is curious is even if the
> class is not instantiated (sp) I am using 12 bytes of global data. Each
> extra virtual function adds another 4 bytes. Now this is not usually a
> problem, but I want to put this code in a shared library on the Palm,
> and I am not allowed any global data.
>
> My question is 2 fold
>
> 1) Why is this generating global data? It seems the virstual function
> table would have to be stored with the instance of the object, since the
> type of object won't be known until run time.
Virtual method tables are stored in the global section. Its just the way the CW
implementation does things and for most
architectures, this isn't a problem. I guess that PalmOS wasn't anticipated. :-) I
think a better way would have been to use code
offsets (but then I'm thinking off the top of my head and not too deeply about it).
Also, what makes you think that the type won't be known until runtime? The type is
actually known at compile time.
> 2) Is there anyway around this, other than abandoning virtual
> functions. This is not too bad in my case, but it would obscure a
> rather easy to understand piece of code.
Just 'cause virtual methods are not supported in notification handlers such as alarms,
doesn't mean that you should abandon them.
I don't believe that there is a way around this.
Kind regards,
Christopher
--
Christopher Hunt
Class Action Pty. Ltd.
Complete time zone management for the Palm(tm) connected organizer.
Check out http://www.classactionpl.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html