Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Calling DLL in Delphi program

williamdiaz
Beginner
337 Views
Hi,
I need make a DLL in Fortran in order to use some
functions (procedures) in Delphi
my Fortran Source Code (sample) is
! Fortran part of a Fortran DLL example. This
SUBROUTINE SUMAR(X, Y, R)
! Specify that SUMAR is exported to a DLL
! and that the external name is 'SUMAR'
!DEC$ ATTRIBUTES DLLEXPORT :: SUMAR
!DEC$ ATTRIBUTES ALIAS:'SUMAR' :: SUMAR
IMPLICIT NONE
INTEGER X,Y,R
Y = X * 2
R = X * 4
RETURN
END

but, when i Try to use in Delphi, it produces a access violation runtime error;
can anybody help me please
0 Kudos
1 Reply
Jugoslav_Dujic
Valued Contributor II
337 Views
What's the Delphi declaration of it? It should be:
procedure SUMARvar x: Integer; var y: Integer, var r: Integer);
   stdcall; external 'yourdll.dll' name 'SUMAR';
(Maybe it could be written more succinctly, but I'm not sure about Delphi parsing rules so I went on the safe side). The keys are "stdcall" and "var" (by reference).

Jugoslav
0 Kudos
Reply