struct Nobody_Expects_The_Spanish_Inquisition{};int main(){ throw Nobody_Expects_The_Spanish_Inquisition();}@H_502_3@输出显示在Ideone:
terminate called after throwing an instance of Nobody_Expects_The_Spanish_Inquisition‘
windows的类似输出:
Unhandled exception at 0x760fb727 in Test.exe: Microsoft C++ exception: Nobody_Expects_The_Spanish_Inquisition at memory location 0x001ffea3..
可以看出,最终的程序集似乎已经包含了异常的名称,或者有另一种获取名称的方法.
这可以被视为某种反思吗?或者,如果实际可以显示异常的名称,它是否依赖于编译器/ OS?
解决方法 它依赖于编译器.显然,编译器很容易发现每个throw,并将每个抛出的对象的类型编码到可执行文件中.但是没有要求他们应该这样做.考虑到这一点,异常必须在抛出时复制到一个奇怪的依赖于实现的空间.因此,通过此机制可以访问特定编译器的运行时,可以访问其类型的名称.
总结以上是内存溢出为你收集整理的C已经有某种反思吗?全部内容,希望文章能够帮你解决C已经有某种反思吗?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
概述考虑这个例子: struct Nobody_Expects_The_Spanish_Inquisition{};int main(){ throw Nobody_Expects_The_Spanish_Inquisition();} 输出显示在Ideone: terminate called after throwing an instance of Nobody_Expects_T 考虑这个例子:
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
c – 使用条件中的do-while循环中声明的变量
上一篇
2022-06-07
c – Linux:Qt Creator调试器在创建QQmlApplicationEngine时挂起
下一篇
2022-06-07
评论列表(0条)