> > You are using the StartupCode.lib library, which is for C
> > only.  It doesn't know about C++ constructors.
>
> Thanks for your reply... but I'm not sure that this is the problem. I have
> overridden operator new and delete and have no trouble allocating
non-static
> objects (see the code below). Only when using a static member do I get the
> link error "Link Error: StartupCode.c: Entry Point '__InitCode__' is
> undefined." ie. if class A wasn't there, I could happily new a B...

Did you try the solution to see if it would work?  The reason I say
that is I think the problem is when you have a static
variable, it is much like having a global variable.  You now
have a variable that must be constructed before PilotMain() begins.
C variables do not have any special constructors that get called
so all of these variables can be initialized by the compiler at
compile time and no runtime code needs to be executed for them.
But C++ objects, like class A have constructors that
must be called at runtime to do the initialization.  So it stands
to reason that some intialization function must get called
before PilotMain that goes and calls the constructors for
all of the global/static objects in the program.  It so
happens that this initialization function is called __InitCode__
and it is defined in the C++ library.  The compiler probably
sees that you have some global/static C++ objects so
it generates a call to this function and you get the error
when the function is not linked with your program.
At least, that's my theory anyways...

Brandon

>
> class Allocatable
> {
> public:
> virtual ~Allocatable() {}
> void *operator new(unsigned long aSize) {
> return MemPtrNew(aSize);
> }
> void operator delete(void *aPtr, unsigned long aSize) {
> MemPtrFree(aPtr);
> }
> };
>
> class B : public Allocatable {
> };
>
> class A : public Allocatable {
> static B b;
> };
>
> B A::b;
>
> ______________________________________________
> FREE Personalized Email at Mail.com
> Sign up at http://www.mail.com/?sr=signup
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html
>
>


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to