Undefined Virtual Function Table
jwarner6@csc.com
jwarner6@csc.com
Wed Jun 30 09:05:00 GMT 1999
Thank you for the responses. We managed to find the underlying cause of
the error: apparently within our 15,000+
lines of code spread over four files there were multiple occurances of the
'#pragma interface' directive, and we
never had them all commented out at the same time. We are trying to make
minimal changes to the code as we port
between two unix environments, so the code is changed back if a potential
solution does not work.
This pragma directive [interface] is supposed to reduce the size of object
files by removing extra information
from object files, eg. inlined code & virtual tables, are retained only in
one object file in a library, not
redundantly included in each object of the library. Unfortunately based on
some documentation that we have seen
on the internet [url not available] this pragma is currently not
implemented perfectly and the code is in transition.
Seeing first hand the results of using this directive we agree with the
idea of not using this directive until its
implementation is perfected. Included below is an example class that we
were planning that led us to the discovery
of the solution. Thank you once again for all of your help.
Sincerely,
James Warner and David Mitchell
//********* OldClass.H *********//
enum APL_boolean {FALSE, TRUE };
#define NULL 0
class OldClass
{
public:
OldClass()
{
version = 1;
common_thing = (int*)NULL;
common_thing_count = 0;
}
virtual ~OldClass ( ) { }
virtual APL_boolean reset_to_defaults();
virtual int* alloc_bar(int bar_type) = 0;
virtual int pack_thing(int x, char *buffer) = 0;
int max_common_things() { return
common_thing_count; }
void deactivatefoo ( ) { *fooActive = FALSE; }
APL_boolean fooIsActive ( ) const { return *fooActive; }
void set_common_thing(char* t, int n);
int* get_it();
protected:
int version; // Version number.
int common_thing_count;
int* common_thing;
APL_boolean* fooActive;
float* foo;
private:
OldClass ( const OldClass & ); // Not defined.
OldClass & operator = ( const OldClass & ); // Not defined.
};
//********* OldClass.C *********//
#include "OldClass.H"
APL_boolean OldClass::reset_to_defaults()
{ return TRUE; }
void OldClass::set_common_thing(char* t, int n) { }
int* OldClass::get_it() { int *x; int y; x = &y; return x; }
//********* NewClass.H *********//
#include "OldClass.H"
#ifdef GNU // this is the underlying cause of our problem
#pragma interface // commenting this out will cause the virtual table
#endif // to be defined properly
class newClass : public OldClass
{ public:
newClass();
newClass(int name);
virtual ~newClass();
int member_func();
int* get_int ( int* id, int bar_type);
APL_boolean reset_to_defaults ();
APL_boolean clear_thing() { return reset_to_defaults(); }
int* alloc_bar(int bar_type);
int pack_thing(int x, char *buffer);
private:
int moreData;
int * moreDataPtr;
};
//********* NewClass.C *********//
#include "NewClass.H"
#ifndef NULL
#define NULL 0
#endif
newClass::newClass()
{ moreData = 3;
moreDataPtr = new(int);
}
newClass::newClass(int name)
{ moreData = 3;
moreDataPtr = new(int);
}
int newClass::member_func()
{ return 0; }
int * newClass::get_int (int * id, int bar_type)
{ return moreDataPtr; }
APL_boolean newClass::reset_to_defaults()
{ return TRUE; }
newClass::~newClass()
{ delete moreDataPtr; }
More information about the Gcc
mailing list