Code: Select all
x86_64-pc-elf/lib/libaos/baselib/thread.o:(.rodata._ZTI11thread_base[_ZTI11thread_base]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
Code: Select all
x86_64-pc-elf/lib/libaos/baselib/thread.o:(.rodata._ZTI11thread_base[_ZTI11thread_base]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
Code: Select all
http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/cxxabi_8h.html
Code: Select all
http://koders.com/cpp/fid645659D1540BDC33C20F6992E1C57E91878EF60B.aspx?s=__cxxabiv1
Code: Select all
namespace std
{
class type_info
{
private:
const char* tname;
public:
virtual ~type_info ( void ) ;
type_info ( const type_info& ) ;
explicit type_info ( const char* ) ;
const char* name ( void ) const ;
bool operator == ( const type_info& ) const ;
bool operator != ( const type_info& ) const ;
};
}
namespace __cxxabiv1
{
#define ADD_CXX_TYPEINFO_HEADER(t) \
class t : public std::type_info \
{ \
public: \
virtual ~t ( void ); \
explicit t ( const char* ); \
} \
ADD_CXX_TYPEINFO_HEADER ( __fundamental_type_info );
ADD_CXX_TYPEINFO_HEADER ( __array_type_info );
ADD_CXX_TYPEINFO_HEADER ( __function_type_info );
ADD_CXX_TYPEINFO_HEADER ( __enum_type_info );
ADD_CXX_TYPEINFO_HEADER ( __pbase_type_info );
ADD_CXX_TYPEINFO_HEADER ( __pointer_type_info );
ADD_CXX_TYPEINFO_HEADER ( __pointer_to_member_type_info );
ADD_CXX_TYPEINFO_HEADER ( __class_type_info );
ADD_CXX_TYPEINFO_HEADER ( __si_class_type_info );
ADD_CXX_TYPEINFO_HEADER ( __vmi_class_type_info );
#undef ADD_CXX_TYPEINFO_HEADER
}
Code: Select all
namespace std
{
type_info::~type_info ( void )
{
}
type_info::type_info ( const type_info& arg )
: tname ( arg.tname )
{
}
type_info::type_info ( const char* pname )
: tname ( pname )
{
}
const char* type_info::name ( void ) const
{
return tname;
}
bool type_info::operator == ( const type_info& arg ) const
{
return tname == arg.tname;
}
bool type_info::operator != ( const type_info& arg ) const
{
return tname != arg.tname;
}
}
namespace __cxxabiv1
{
#define ADD_CXX_TYPEINFO_SOURCE(t) \
t::~t ( void ) {;} \
t::t ( const char* n ) : std::type_info ( n ) {;} \
ADD_CXX_TYPEINFO_SOURCE ( __fundamental_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __array_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __function_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __enum_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __pbase_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __pointer_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __pointer_to_member_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __class_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __si_class_type_info )
ADD_CXX_TYPEINFO_SOURCE ( __vmi_class_type_info )
#undef ADD_CXX_TYPEINFO_SOURCE
}
You also need to write your own dynamic_cast, if you want to fully support RTTI.Cemre wrote:PS: you can only to typeid with this, you need to do other stuff to implement try catch exception handling
Code: Select all
class C
{
C(int i);
explicit C(double d);
}
int main(int, char**)
{
C fromInt = 20;
//C fromDoubleE = 3.14159; // Fails
C fromDoubleOK(3.14159);
}
Code: Select all
class C
{
static implicit operator C(int from); // int -> C
static explicit operator double(C from); // C -> double
}
You needn't prefer .NET for that, C++ allows it as well. C++ does allow other ways too, which I prefer.Habbit wrote: Or so I think, I didn't try to compile this code
If you ask me, I prefer the .NET way: both to and from conversion operators are declared as static methods like this:Code: Select all
class C { static implicit operator C(int from); // int -> C static explicit operator double(C from); // C -> double }
AFAIK, C++ conversion operators are only from the class being declared to another type (like [tt]class C { operator int(void) const; }[/tt]). All conversions from other types to the class being declared must be done either through constructors or assignment operators.Candy wrote: You needn't prefer .NET for that, C++ allows it as well. C++ does allow other ways too, which I prefer.
Those will follow, this was just for being able to not say -fno-rtti to the compiler. I'll do those on-demand at first (when I accidentally use them and get a compile error) and when I think I should add them explicitly.bluecode wrote:You also need to write your own dynamic_cast, if you want to fully support RTTI.Cemre wrote:PS: you can only to typeid with this, you need to do other stuff to implement try catch exception handling