从向量< float>切换时出错向量<短> [英] Error switching from vector<float> to vector<short>

查看:135
本文介绍了从向量< float>切换时出错向量<短>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用我正在制作的地方,我想要改变我从浮动到短路创建的向量。我的代码在这样的头文件中:

I have an app I'm making where I would like to change a vector I'm creating from float to short. My code is in a header file like this:

vector<float> vertices;

它工作正常,但如果我将其切换为:

and it works fine, but if I switch it to this:

vector<short> vertices;

并编译,它崩溃时出现以下错误:

and compile, it crashes with the following error:

malloc: *** error for object 0x1035804: incorrect checksum for freed object
 - object was probably modified after being freed. *** set a breakpoint in
malloc_error_break to debug

我不知道发生了什么。如果它有帮助,这是我正在为iPad开发的OpenGL应用程序。

I have no idea what's going on. If it helps, this is an OpenGL application I'm developing for the iPad.

推荐答案

我仍然不知道为什么当我将矢量从浮动变为短时我的应用程序不会运行,但是我通过创建一个新的短裤矢量对象并使用它来解决问题。没有更多问题,并按预期工作。

I still don't know why my app wouldn't run when I changed my vector from float to short, but I solved the problem by creating a new vector object of shorts and using that instead. No more problems and works as expected.

这篇关于从向量&lt; float&gt;切换时出错向量&lt;短&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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