小编non*_*237的帖子

std :: string构造函数会破坏指针

我有一个Entity类,它包含3个指针:m_rigidBody,m_entity和m_parent.在Entity :: setModel(std :: string model)的某个地方,它正在崩溃.显然,这是由m_entity中的错误数据引起的.奇怪的是,我在构造函数中将其弄糊涂,从那时起就没有触及它.我调试了它并在其上放置了一个观察点,并且发现m_entity成员正在std :: string的构造函数中被更改,这是在将const char*转换为用于setModel调用的std :: string时被调用的.我在Mac上运行,如果这有帮助(我想我记得Mac上的std :: string有些问题).关于发生了什么的任何想法?

编辑:这是GEntity的代码:

GEntity::GEntity(GWorld* world, unsigned long int idNum) {
    GEntity(world, idNum, btTransform::getIdentity());
}

GEntity::GEntity(GWorld* world, unsigned long int idNum, btTransform trans) : m_id(idNum), m_trans(trans), m_world(world) {
    // Init unused properties
    m_rigidBody = NULL;
    m_entity = NULL; // I'm setting it here
    m_parent = NULL;

    // Find internal object name
    std::ostringstream ss;
    ss << "Entity" << idNum << "InWorld" << world;
    m_name = ss.str();

    // Create a scene node …
Run Code Online (Sandbox Code Playgroud)

c++ string macos memory-corruption

3
推荐指数
1
解决办法
1093
查看次数

boost :: qi :: parse似乎导致编译错误

我正在尝试使用Boost :: Spirit编写解析器,并且我编写了解析器并进行了编译.问题是,当我尝试编译解析函数时,编译器会抛出一堆模板错误.这是Qi语法:

template<typename Iterator>
struct etf_parser : qi::grammar<Iterator, std::map<std::string, etfnode>(), ascii::space_type> {
    etf_parser() : etf_parser::base_type(start) {
            using qi::int_;
            using qi::lit;
            using qi::double_;
            using qi::bool_;
            using qi::lexeme;
            using ascii::char_;

            quoted_string %= lexeme['"' >> +(char_ - '"') >> '"'];

            dataVal %= (quoted_string | double_ | int_ | bool_ | listObj | pairObj | mapObj);

            pairObj %= ('<' >> dataVal >> ',' >> dataVal >> '>');

            listObj %= '{' >> dataVal % ',' >> '}';

            mapKey %= +qi::char_("a-zA-Z_-0-9.");
            mapPair %= mapKey >> …
Run Code Online (Sandbox Code Playgroud)

c++ boost compiler-errors boost-spirit

3
推荐指数
1
解决办法
1093
查看次数

可可屏幕捕捉?

你如何在Cocoa中捕获屏幕的NSImage?我需要知道最快的方式,因为我正在尝试制作一个截屏视频应用.

cocoa objective-c

1
推荐指数
1
解决办法
2358
查看次数

可可内存编辑检查

我如何使用Cocoa编辑其他应用程序的内存?我知道编辑必须以root身份完成,但我怎么能在第一时间完成呢?

memory macos cocoa low-level

0
推荐指数
1
解决办法
352
查看次数