从向量< float>切换时出错向量<短> [英] Error switching from vector<float> to vector<short>
问题描述
我有一个应用我正在制作的地方,我想要改变我从浮动到短路创建的向量。我的代码在这样的头文件中:
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.
这篇关于从向量< float>切换时出错向量<短>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!