Recent

Author Topic: AV - and DLL  (Read 4281 times)

tomek

  • Jr. Member
  • **
  • Posts: 85
AV - and DLL
« on: March 08, 2011, 09:48:40 am »
This is my code of dll usage:
Code: [Select]
implementation
procedure proced_(var i:Real); stdcall; external 'libo3.dll';
...
procedure TForm1.Button1Click(Sender: TObject);
var
  r:Real;
begin
  r:=6;
  proced_(r);
  Label1.Caption:=FloatToStr(r);
end;

procedure "proced_" in dll changes the value of r, and r on label is correct, but at end of Button1Click I get AV in TControlClick - include/control.inc

I forgot something in calling to the library?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12634
  • FPC developer.
Re: AV - and DLL
« Reply #1 on: March 08, 2011, 09:56:34 am »
This is my code of dll usage:
Code: [Select]
implementation
procedure proced_(var i:Real); stdcall; external 'libo3.dll';
...
procedure TForm1.Button1Click(Sender: TObject);
var
  r:Real;
begin
  r:=6;
  proced_(r);
  Label1.Caption:=FloatToStr(r);
end;

procedure "proced_" in dll changes the value of r, and r on label is correct, but at end of Button1Click I get AV in TControlClick - include/control.inc

I forgot something in calling to the library?

No, but maybe it is not stdcall, but e.g. cdecl?

tomek

  • Jr. Member
  • **
  • Posts: 85
Re: AV - and DLL
« Reply #2 on: March 08, 2011, 10:19:36 am »
No, but maybe it is not stdcall, but e.g. cdecl?

Thanks, with cdecl is ok.
But I wonder why that because library was compiled as stdcall calling convention.
This is fortran g95 "g95 -shared -mrtd -o libo3.dll libo3.o" - mrtd sets to stdcall calling convention.
In any case, work ok with cdecl. Thanks for help.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: AV - and DLL
« Reply #3 on: March 08, 2011, 05:23:55 pm »
Quote
This is fortran g95 "g95 -shared -mrtd -o libo3.dll libo3.o" - mrtd sets to stdcall calling convention.
Well for that you should ask in g95 forum.

 

TinyPortal © 2005-2018