+ -
当前位置:首页 → 问答吧 → 请教一个C函数的DELPHI声明

请教一个C函数的DELPHI声明

时间:2011-09-01

来源:互联网

C/C++ code

  void  LowpassFilter(int32_t order,Double *arrayData,Double sampleF,Double HighCutoff,Double Lowcutoff,Double *filterData,Int32_t *error,Int32_t Len,Int32_t Len2);



下面是我的DELPHI声明
Delphi(Pascal) code

procedure  LowpassFilter(order:Integer;Input:pDouble ;SamplingFredFs,highCutoffFreqfh,LowPassFreqFl:Double;Output:PDouble;error:PInteger ;len1:Integer ;len2:Integer);stdcall   ;external 'SharedLib.dll'




现在就是报内存地址越界错误,不知道怎么回事
下面是我调用的示例
Delphi(Pascal) code

procedure TForm1.btn1Click(Sender: TObject);
var
  a:array[0..1] of double ;
  b:array[0..1] of double ;
  err:PInteger ;
begin
  a[0]:=5;
  a[1]:=6;
  b[0]:=0;
  b[1]:=0;
 LowpassFilter(2,@a[0],2000.0,2000.0,200.0,@b[0],err ,2,2);
  ShowMessage(FloatToStr(b[0]));
end;

end.

作者: wangwei244157887   发布时间: 2011-09-01

越界?是不是a或是b申请的不够啊,你弄大点试试
都弄成
  a:array[0..254] of double ;
  b:array[0..254] of double ;
记得要初始化下。

作者: m617105   发布时间: 2011-09-01

你把error声明为pinteger,但是调用时并没有指向具体数据,传了一个空指针。

作者: DelphiGuy   发布时间: 2011-09-01