type_info,vtable [英] type_info, vtable
本文介绍了type_info,vtable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是type_info函数,更具体地说,什么是type_info节点?
这些是否与vtable有关?
我看过链接器错误如此as:
对SomeClass type_info节点的未定义引用或者
对SomeClass type_info函数的未定义引用
这究竟意味着什么?什么是链接器寻找?
谢谢。
解决方案
" sks_cpp" < SK ***** @ hotmail.com>在留言中写道
新闻:Nn ******************* @ news2.central.cox.net ..
|什么是type_info函数,更具体地说,什么是type_info节点?
|这些与vtable有什么关系吗?
有点儿。在几个实现中,vtable存储了type_info数据结构的地址
。
这个数据结构用于实现运行时类型识别
(RTTI),
a功能,它是异常处理,dynamic_cast调用,
和typeid运算符的实现所必需的(参见header< typeinfo>)。 />
|我见过链接器错误,例如:
| 对SomeClass type_info节点的未定义引用或者
| 对SomeClass type_info函数的未定义引用
某些C ++编译器实现允许为RTTI启用/禁用支持
。您可能需要为某些文件启用它...
hth
-
Ivan Vecerina<> http://www.post1.com/~ivec
Brainbench MVP for C ++<> http://www.brainbench.com
>
Ivan Vecerina写道:
这个数据结构用于实现运行时类型识别
(RTTI),一个功能这是异常处理所必需的,
RTTI不需要进行异常处理,也不足够。
Rolf Magnus < RA ****** @ t-online.de>在消息中写道
新闻:bh ************* @ news.t-online.com ...
| Ivan Vecerina写道:
|
| >此数据结构用于实现运行时类型标识
| > (RTTI),异常处理所需的功能,
|
| RTTI不需要进行异常处理,也不足够。
我没有声称它已经足够了。
但是RTTI需要匹配捕获处理程序和异常。
考虑:
#include< vector>
#include< string> ;
#include< iostream>
#include< exception>
int main()
{
尝试{
std :: vector< std :: string> tooBig(1UL<<< 31,只是一些字符串);
}
catch(std :: exception& x){
std :: cerr<< 失败:<<< x.what()<< std :: endl;
}
}
C ++运行时如何处理此内存分配失败
没有RTTI?
问候,
Ivan
-
http://www.post1.com / ~vevec
What is a type_info function, more particularly, what is a type_info node?
Are these related to the vtable by any means?
I have seen linker errors such as:
"undefined reference to SomeClass type_info node" or
"undefined reference to SomeClass type_info function"
What does that really mean? What is the linker looking for?
Thanks.
解决方案
"sks_cpp" <sk*****@hotmail.com> wrote in message
news:Nn*******************@news2.central.cox.net.. .
| What is a type_info function, more particularly, what is a type_info node?
| Are these related to the vtable by any means?
Somewhat. In several implementations, the vtable stores the address of
the type_info data structure.
This data structure is used to implement Run-Time Type Identification
(RTTI),
a feature which is required for exception handling, dynamic_cast calls,
and the implementation of the typeid operator (see header <typeinfo>).
| I have seen linker errors such as:
| "undefined reference to SomeClass type_info node" or
| "undefined reference to SomeClass type_info function"
Some C++ compiler implementations allow to enable/disable support
for RTTI. You probably need to enable it for some files...
hth
--
Ivan Vecerina <> http://www.post1.com/~ivec
Brainbench MVP for C++ <> http://www.brainbench.com
Ivan Vecerina wrote:
This data structure is used to implement Run-Time Type Identification
(RTTI), a feature which is required for exception handling,
RTTI isn''t need for exception handling, neither would it be sufficient.
"Rolf Magnus" <ra******@t-online.de> wrote in message
news:bh*************@news.t-online.com...
| Ivan Vecerina wrote:
|
| > This data structure is used to implement Run-Time Type Identification
| > (RTTI), a feature which is required for exception handling,
|
| RTTI isn''t need for exception handling, neither would it be sufficient.
I did not claim it was sufficient.
But RTTI is needed to match catch handlers with exceptions.
Consider:
#include <vector>
#include <string>
#include <iostream>
#include <exception>
int main()
{
try {
std::vector<std::string> tooBig(1UL<<31,"just some string");
}
catch(std::exception& x) {
std::cerr << "Failure: "<<x.what()<<std::endl;
}
}
How would the C++ run-time handle a failure of this memory allocation
without RTTI?
Regards,
Ivan
--
http://www.post1.com/~ivec
这篇关于type_info,vtable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文