标题:[求助]stack overflow的问题
只看楼主
fish0928
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-6-24
 问题点数:0 回复次数:1 
[求助]stack overflow的问题
我在delphi里调用一个vc的dll文件做运算,算一会就会出现stack overflow的问题~~
是不是我定义的调用有问题啊~ 哪位来帮忙看看啊~~~
这个程序以前都是用C写的,现在要求改成delphi的,由于那个函数实在我是看不懂翻不过来,就想把它弄成dll来用,可是还出现了这个问题,这个函数是用来处理数据的,弄不出来怎么办啊。。。555.。。。

我在delphi里定义的
Function ioCode(AFloat:Double):Integer;
stdcall;far;external'mydll.dll' name 'ioCode;

调用时
test:array[0..4000000]of Single;

for i=0 to n do
num:=ioCode(test[i]);

这个i没运行到n的时候就会提示错误了。。。麻烦各位帮忙给看看啊~~ 万分感谢!

C里dll的程序

extern "C"{
_declspec(dllexport) int ioCode(float AFloat)
{
int LongInt;
int IBM_exp;
int IBM_fraction;
int TheSign;
float f=AFloat;
char * pp = (char *)(&f);
int ATemp = *((int *) (pp));
int Sun_exp = ATemp & 0x7f800000;
int Sun_fraction = ATemp & 0x7fffff;
short int AMod = Sun_exp-(IBM_exp << 2);
TheSign = (ATemp & 0x80000000)>>31;
Sun_exp = Sun_exp >>23;
if ( Sun_exp == 0 && Sun_fraction == 0 )
{
IBM_exp = 0x40;
IBM_fraction = 0;
IBM_exp +=64;
LongInt = (TheSign<<31)|(IBM_exp<<24)|IBM_fraction;
return LongInt;
}
if ( Sun_exp == 0 && Sun_fraction != 0 )
{
Sun_exp = 253;
}
Sun_exp = Sun_exp-126; // Sun_exp-127+1
IBM_fraction = Sun_fraction | 0x800000 ; // the highest bit is 1
//exponent/4
IBM_exp = Sun_exp >> 2;
AMod = Sun_exp-(IBM_exp << 2);
if ( AMod != 0 )
{
IBM_exp++;
AMod = 4-AMod;
}
IBM_fraction = IBM_fraction >> AMod;
IBM_exp +=64;
LongInt = (TheSign<<31)|(IBM_exp<<24)|IBM_fraction;
return LongInt;
}
};
搜索更多相关主题的帖子: overflow stack 
2007-06-13 10:12
anthony634
Rank: 6Rank: 6
来 自:西南交大
等 级:贵宾
威 望:24
帖 子:653
专家分:10
注 册:2006-6-8
得分:0 
数组下标太大了
2007-06-13 12:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-147051-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020009 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved