Re: typeid() headaches (library to main executable)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Andreas,

Note that "GCC" 2.96 is really a maverick (unsanctioned by GNU) release from Red Hat.  There wasn't a GCC 2.96, per se.  The backstory behind it is interesting, and available on-line (q.v. via Google), but isn't germane so I won't go into details.

So when the GCC documentation speaks of a new C++ ABI in GCC 3.0, that's new from GCC 2.95.  And the new C++ ABI underwent some incompatible changes between 3.0 and 3.1, and 3.1 and 3.2.  As I understand the situation, 3.2 - 3.3 - 3.4 have a compatible C++ ABI.  I'm not sure about the recent GCC 4.0.

Anyway, given the description you provided, I tried to recreate the situation and was unable to reproduce the undefined reference you are running into.

I also used your program.h, program.cpp, libtest.cpp and makefile -- and was unable to reproduce the undefined reference you are running into.  Rather I'm seeing this...

> make
g++  -o program program.cpp
program.cpp:6: redefinition of `void CTestClass::mytest()'
program.h:13: `virtual void CTestClass::mytest()' previously defined here

program.cpp:6: no `void CTestClass::mytest()' member function declared in class
   `CTestClass'
make: *** [program] Error 1

...which appears to be due to CTestClass::mytest being defined twice.

Could you fix your short example code that reproduces the problem?

Also, since you specified ALL your virtual functions as inline, you may want to consider -fkeep-inline-functions.  As I understand it, the type information is generated with the first virtual (non-inline) function is generated.  If all your virtual functions are inline (which is very, very odd, by the way, since the whole point to a virtual function is to be accessed polymorphically through the virtual function pointer table, and you cannot have a virtual function pointer access to a method that is inlined), the compiler may not trigger generation of type information.

Another consideration is that your base class CBaseTestClass does not have a virtual destructor, yet is used as a public base class for CTestClass.  Either you should put in a virtual destructor for CBaseTestClass, or you should make the base class private in CTestClass.

Thanks,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux