Subject | How to declare a UDF function in Delphi (cdecl or stcall) |
---|---|
Author | ICAMSoft |
Post date | 2008-08-07T19:35:57Z |
Hi to group
I want to write some new udf function in Delphi.
Lookinng at Documentation in http://www.firebirdsql.org i found both kind of declarations
--------
With cdecl in http://www.firebirdsql.org/index.php?op=useful&id=deatz_udf
• function Modulo(var i, j: Integer): Integer; cdecl; export;
• Implement the routine in the implementation section:
function Modulo(var i, j: Integer): Integer;
begin
if (j = 0) then
result := -1 // just check the boundary condition, and
// return a reasonably uninteresting answer.
else
result := i mod j;
end;
-----------
And with stdcall in http://www.firebirdfaq.org/faq83/
function ChangeMyString(const p: PChar): PChar; stdcall;
var
s: string;
begin
s := DoSomething(string(p));
Result := ib_util_malloc(Length(s) + 1);
StrPCopy(Result, s);
end;
-------
Can somebody help and say what is the right kind of declaration?
PS: The funny thing is that i discovered that in previous (different) applications (with FB 2.0.x) i have used both kind of declarations and for many months i haven't been informed for any problem...
Thanks in advance for any info
Tassos Kyriakos
Athens, Greece
tkyr@...
________________________________________________
ICAMSoft – Smart Computer Applications
I want to write some new udf function in Delphi.
Lookinng at Documentation in http://www.firebirdsql.org i found both kind of declarations
--------
With cdecl in http://www.firebirdsql.org/index.php?op=useful&id=deatz_udf
• function Modulo(var i, j: Integer): Integer; cdecl; export;
• Implement the routine in the implementation section:
function Modulo(var i, j: Integer): Integer;
begin
if (j = 0) then
result := -1 // just check the boundary condition, and
// return a reasonably uninteresting answer.
else
result := i mod j;
end;
-----------
And with stdcall in http://www.firebirdfaq.org/faq83/
function ChangeMyString(const p: PChar): PChar; stdcall;
var
s: string;
begin
s := DoSomething(string(p));
Result := ib_util_malloc(Length(s) + 1);
StrPCopy(Result, s);
end;
-------
Can somebody help and say what is the right kind of declaration?
PS: The funny thing is that i discovered that in previous (different) applications (with FB 2.0.x) i have used both kind of declarations and for many months i haven't been informed for any problem...
Thanks in advance for any info
Tassos Kyriakos
Athens, Greece
tkyr@...
________________________________________________
ICAMSoft – Smart Computer Applications