STL向量< float>紧急 [英] STL vector<float> crash

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

问题描述

我将基本必需品放在控制台应用程序中。

http://home.earthlink.net/~mcolaso​​no/tmp/degub.zip

打开output.fft并将其加载到vector< ;浮动>螺丝

up,但input1.dat不行。它也会加载矢量。当你返回控制台时,或者在[wx] Windows应用程序中,消息循环时,只需要
。我认为它与

向量< float>有关超出范围并试图释放记忆,但是

不知道为什么会这样做。 fft文件是512个浮点数,并且我将
转换为test.txt的实际值(来自向量b / b崩溃的向量,BTW)。


我在VC ++中做到了。也许另一个编译器或操作系统不会有一个问题

用它。


如果有人可以尝试一下,我会很感激发生。


提前致谢。

-

最好的问候,

Mike

I put the bare essentials in a console app.

http://home.earthlink.net/~mcolasono/tmp/degub.zip

Opening output.fft and loading it into a vector<float> screws
up, but input1.dat doesn''t. It does load the vector, too. It just
craps out when you return to the console, or in a [wx]Windows app,
the message loop. I think it has something to do with the
vector<float> going out of scope and trying to free memory, but
don''t know why it would do that. The fft file is 512 floats and I
converted the actual values (which came out of the vector which
crashed, BTW) to test.txt.

I did it in VC++. Maybe another compiler or OS won''t have a prob
with it.

I''d appreciate it if someone could try it out and see what happens.

Thanks in advance.
--
Best Regards,
Mike

推荐答案

Active8写道:
Active8 wrote:
我把基本要素放在控制台应用程序中。
I put the bare essentials in a console app.




实际上,你没有!这段代码至少使用了一个[实际上甚至不需要b $ b b],特定于环境的标题,我怀疑你是否已经将它减少到暴露问题的最小代码。

您对标题使用了错误的约定(您的标题不得使用

尖括号;尖括号是为系统保留的; / b $ b系统,即标准库标题),你将字符串

文字传递为''char *''(你不能:字符串文字的类型是

'' char const(&)[n]''衰变为''char const *''),你不会检查任何错误代码!


一个最小的例子通常需要30行代码。

在将代码减少到最小数量的情况下,你通常也会因某些思想而绊倒
...

-

< mailto:di *********** @ yahoo.com> < http://www.dietmar-kuehl.de/>

< http://www.contendix.com> - 软件开发&咨询



Actually, you didn''t! This code uses at least one [actually even
unnecessary], environment specific header and I doubt that you
have reduced it to the bare minimum of code exposting the problem.
You are using the wrong convention for headers (you shall not use
angle brackets for your headers; angle brackets are reserved for
the system, i.e. the standard library headers), you pass string
literals as ''char*'' (you can''t: the type of a string literals is
''char const(&)[n]'' which decays to a ''char const*''), and you don''t
check for any error codes!

A minimal example typically takes something like 30 lines of code.
In reducing the code to a minimal amount you would normally also
stumble over some thinko...
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting


" Dietmar Kuehl" <二*********** @ yahoo.com>在留言中写道

news:11 ********************** @ f14g2000cwb.googlegr oups.com ......
"Dietmar Kuehl" <di***********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
你将字符串
文字传递为''char *''(你不能:字符串文字的类型是''char const(&)[ n]''衰变为''char const *''
you pass string
literals as ''char*'' (you can''t: the type of a string literals is
''char const(&)[n]'' which decays to a ''char const*''




....嗯,你不忘记允许的兼容性黑客攻击

字符串文字衰减为char *?



....umm, aren''t you forgetting about the compatibility hack that permits a
string literal to decay to char*?


2005年3月1日星期二15:56:29 GMT,Andrew Koenig写道:
On Tue, 01 Mar 2005 15:56:29 GMT, Andrew Koenig wrote:
" Dietmar Kuehl"< di *********** @ yahoo.com>在消息中写道
新闻:11 ****** ****************@f14g2000cwb.googlegr oups.com ...
"Dietmar Kuehl" <di***********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
你将字符串
文字传递为''char *''(你不能:字符串文字的类型是''char const(&)[n]'',它衰变为''char const *''
you pass string
literals as ''char*'' (you can''t: the type of a string literals is
''char const(&)[n]'' which decays to a ''char const*''



...嗯,ar难道你忘了兼容性hack允许
字符串文字衰变为char *?



...umm, aren''t you forgetting about the compatibility hack that permits a
string literal to decay to char*?




我见过很多代码以这种方式传递文字。我开始了

<>包括当我将文件放在一个单独的目录中并且意味着

将这些文件更改为引号时。如果我读过那<>保留给系统

文件,我忘记了,但现在我知道了。


-

最好的问候,
Mike



I''ve seen plenty of code that passes literals that way. I started
the <> includes when I put the files in a separate dir and meant to
change those to quotes. If I''ve read that <> is reserved for system
files, I forgot, but now I know.

--
Best Regards,
Mike


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

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