C++ again...
Posted: Wed Jan 29, 2003 3:27 pm
I'm having some problems with inheritance, overloading inherited functions, and virtual functions.
Any form of virtual (virtual, and pure virtual) function (you need a virtual deconstructor in any class you will inherit from), causes an invalid op code exception.
BTW, if your using djgpp gcc. Use the support code on my site, and link libsupcxx.a between your kernel stub, and object files, and code for vtable will be enabled for inheritance to work correctly. You will get one undefined reference to __cxa_pure_virtual. From looking around the web for info, I've defined it as so,But I need to research the actually use of this function.
Any ideas how I can find why virtual functions causes an invalid op code? I've found this out by having a default trap handler which prints out which exception had occurred.
Code: Select all
FooBase foo1 = new FooBase() ;
foo1.bar() ; //this works ok
FooSub foo2 = new FooSub() ;
foo2.bar() ; //this works ok
FooBase foo3 = new FooSub() ;
foo3.bar() ; //shouldn't this call FooSub::bar() instead
//of FooBase::bar() ?
BTW, if your using djgpp gcc. Use the support code on my site, and link libsupcxx.a between your kernel stub, and object files, and code for vtable will be enabled for inheritance to work correctly. You will get one undefined reference to __cxa_pure_virtual. From looking around the web for info, I've defined it as so,
Code: Select all
extern "C" void __cxa_pure_virtual (void)
{
k_panic("__cxa_pure_virtual called!") ;
}
Any ideas how I can find why virtual functions causes an invalid op code? I've found this out by having a default trap handler which prints out which exception had occurred.