动态转型指针不是std :: __ non_rtti_object [英] dynamic cast throws pointer is not std::__non_rtti_object

查看:370
本文介绍了动态转型指针不是std :: __ non_rtti_object的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有dynamic_cast的问题。我只是编译了我的项目,并测试了所有的东西在调试模式,然后我试图编译它在发布模式,我已经从调试模式exept优化参数复制每个配置,现在是/ o2,(而调试我设置为/ od)项目编译,但是当它开始加载我的资源我有一段代码在这里有异常:

I'm having problem with dynamic_cast. i just compiled my project and tested every thing in debug mode and then i tried compiling it in release mode, i have copied every configuration from debug mode exept optimization parameter which is now /o2, (while debuging i set it as /od) the project compiled but when it starts loading my resources i got exception in the piece of code here :

for(int j = 1; j < i->second->getParametersNumber();j++)
{
    CCTMXTiledMap* temp = CCTMXTiledMap::tiledMapWithTMXFile(i->second->As<string>(j).c_str());
    CCTMXLayer* ret = NULL;
    for(NSMutableArray<CCNode*>::NSMutableArrayIterator l=temp->getChildren()->begin();!ret && l!=temp->getChildren()->end();l++)
        ret = dynamic_cast<CCTMXLayer*> (*l);
    t1.first = ret;
    templates[i->first].second.push_back(t1);
    templates[i->first].second.back().first->retain();
}

代码中没有任何变化,当我在调试器中检查每个变量时,它应该是,但动态转换是抛出std :: __ non_rtti_object。我做错了什么?

nothing in code changed and when I check in debugger every variable in classes is what it should be but dynamic cast is throwing std::__non_rtti_object. what am i doing it wrong? and i'm using cocos2d-x ,I didn't have enough reputation to add that tag!

推荐答案

在这种情况下,我们可以使用cocos2d-x许多代码更改我发现有一些错误显示自己当代码优化(仍然不知道是否是编译器的mis优化或我的代码有一些问题,但它可能是我的)。这个问题的主要原因是 * l 为NULL。

In this case after many code changes I found out there has to be some bugs which show themselves when code is optimized (still don't know if it's compiler's mis optimization or my code has some problems but it's probably mine). and the main reason for that problem was with *l being NULL.

这篇关于动态转型指针不是std :: __ non_rtti_object的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆