CompuServe Thread

#Link error

5 messages in this thread
#7020From: Jim SchlightJul 15, 1993 1:20 AM
I'm converting a TCL application from THINK C to Symantec C++ by moving classes one at a time to the Starter project, changing the extension from '.c' to '.cp'. When adding the latest class, I get the link error: undefined: CTqBsTable::_vtbl What causes this? How can I get rid of it? Thanks, Jim.
#7028From: Kevin IrlenJul 15, 1993 8:45 AM
(From previous responses to this question:) You'll get this link error anytime a reference to a virtual method is made when the vtable has not been built. The compiler uses the first virtual method in a class to start the vtable, and subsequent methods will use that as a starting point. For example: class X{ public: virtual void foo(void); virtual void bar(void); }; // void X::foo(void) {} // with this commented out, compiler won't build the vtable void X::bar(void) {} void main(void) { X x; x.bar(); // link error for X::_vtbl unitl X::foo defined. } Kevin Irlen Symantec Languages Support
#7037From: Jim SchlightJul 15, 1993 12:36 PM
Kevin, Your reply suggests that the undefined _vtbl error is caused by a virtual member function that is declared but not defined. I've checked the class and every member function that is declared in the '.h' file is defined in the '.cp' file. What should I be looking for? Jim.
#7187From: Jim SchlightJul 19, 1993 11:56 PM
Kevin, My _vtbl link error is related to declaring a destructor method for my class. No destructor method, no link error. The following code demonstrates the problem. What do you suggest I do? Jim. —————————————————— #include "CArray.h" class X : public CArray { public: X (void); // ~X (void); // remove comment -> no vtable virtual void foobar(void); }; X::X(void) {} // X::~X(void) {} // remove comment -> no vtable void X::foobar(void) {} void func(void); void func(void) { X *x; x->foobar(); }
#7225From: Kevin IrlenJul 20, 1993 4:21 PM
This is currently a bug in the compiler. Destructors for Pascal Objects (i.e. descendants of CObject) are not being compiled correctly and this is showing up as a link error. Unfortunately, there is no workaround available; you won't be able to use destructors with Pascal Objects. Kevin Irlen Symantec Languages Support