- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have written a fortran dll to manipulated some data which are stored in allocated array, and I want to put this array into C++ program. But my dll can't do it. I don't understand
fortran program:
C++ programm:
fortran program:
!M = 10, N = 20
!DEC$ ATTRIBUTES C, DLLEXPORT :: GetArray
INTEGER FUNCTION GetArray(Arr, MN)
!MS$ ATTRIBUTES REFERENCE :: Arr
REAL Arr((M+1)*(N+1))
INTENT(OUT) :: Arr
DO J = 0, N
Do I = 0, M
MN = MN + 1
Arr(MN) = I*J
END DO
END DO
GetArray = 0
RETURN
ENDC++ programm:
......
typedef int __stdcall (*FGetArray)(float*, int);
.......
float GetGrid(int *cGrid)
{
FGetArray intGetArray;
float *Arr;
LoadLibrary ...// it's ok
GetProcAddress ... //it's ok
ofstream in("c:\testC1.txt",ios::app);
Arr = new float[1154];
a = intGetArray(Arr);
in<<"
a: "<
All trable in transfer of a array. How to do it?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't see what's wrong? The code looks fine except that there's MN missing from the actual call -- a typo? (This shouldn't compile). Ahh, yes -- it should be int* MN in declaration -- otherwise, MN can't get out of the dll.
Btw, why is GetArray a function that always returns 0? Why not a subroutine?
Jugoslav
Btw, why is GetArray a function that always returns 0? Why not a subroutine?
Jugoslav
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page