View previous topic :: View next topic |
Author |
Message |
dpannhorst
Joined: 29 Aug 2005 Posts: 165 Location: Berlin, Germany
|
Posted: Mon Aug 29, 2005 9:26 am Post subject: Getting Variables in Modules from a DLL |
|
|
Hello everybody,
I want to use the same variable in a main program and in a subroutine in a DLL. Therefore I am using in the main program and in the DLL's subroutine the same MODULE containing the definition of my variable. In the main program I set a value to the variable, but the value in the DLL's subroutine stays everytime at zero! What have I to do to share the variable between main program and DLL? (Compaq Fortran offers a DLL-Export / Import of variables).
Detlef Pannhorst |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8003 Location: Salford, UK
|
Posted: Wed Aug 31, 2005 4:07 am Post subject: Getting Variables in Modules from a DLL |
|
|
At the moment FTN95 does not enable you to link a common block (or module data)
across a main program and a DLL or across two DLLs. If you use the Salford
intrinsic LOC to get the addresses you will find that the two sets of data
have different address spaces.
This limitation already appears on the wish list of things to do when time and resources permit.
What is needed is an EXTERNAL attribute that can be attached to a common block (or module data)
in a way that is analogous to subprograms. Incidentally, you can embed a common block in a
module so adding the feature for a common block alone may be sufficient.
A rather poor alternative is to put all the data into one array (using EQUIVALENCE statements
for the variables) and to pass this array on each call. Since the array is passed by reference,
the overhead is minimal. You could also put the relevant code in an INCLUDEd file. |
|
Back to top |
|
|
|