View previous topic :: View next topic |
Author |
Message |
stevenf87928
Joined: 21 Oct 2016 Posts: 1
|
Posted: Wed Dec 20, 2017 8:53 pm Post subject: Passing Common Block from Main to DLLs |
|
|
Hi,
I am new to using DLLs so forgive me if this is a silly question, but I was wondering if there is anyway to pass Common blocks TO a DLL. I am aware of the reverse behavior of DLLEXPORT of a Common FROM a DLL, but I was wondering if there was a method to go the other direction or at least referencing the Common values? Do you have to convert them to arguments or is there a more elegant solution?
By nature, do DLLs exclude this? I saw one response on these forums saying that that was not possible, but on another compiler's page saw that it was. I'm looking to clear up that confusion.
Thanks for the help! |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Fri Dec 22, 2017 5:18 pm Post subject: |
|
|
In FTN95 there is no facility to dynamically link data in the way that subprograms can be linked in a DLL. This applies to COMMON BLOCKs and to module data.
Each DLL can have its own global data but data cannot be dynamically linked across DLLs etc.
Perhaps the nearest that you could get to this idea is to use the FTN95 extension to the ALLOCATE statement via a "SHARENAME" attribute. This is available for a Win32 platform and details can be found in (for example) FTN95.chm.
A more usual approach is to keep shared data in a small number of arrays (declared in the main program) and to use an initialisation routine to pass the base address or addresses to the DLL at startup. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Sun Dec 24, 2017 12:07 am Post subject: |
|
|
what do you mean by
Quote: | use an initialisation routine to pass the base address or addresses to the DLL at startup. | ? |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Tue Dec 26, 2017 11:14 am Post subject: |
|
|
John,
In FTN95.CHM, use the Search tab with keyword LOC. Then out of the choices, choose 'Other machine level facilities'.
With LOC, you can get the base addresses of any variable or data structure, then pass it as a parameter in a subroutine call, presumably so that your DLL routines then know where to look.
There is a crude example.
I'll assume that the statement "The LOC intrinsic function returns the address of its argument as a 32 bit number." may need to be reinterpreted if you use 64 bit FTN95.
Eddie |
|
Back to top |
|
|
narayanamoorthy_k
Joined: 19 Jun 2014 Posts: 142 Location: Chennai, IN
|
Posted: Sat Jan 13, 2018 1:58 pm Post subject: |
|
|
Thanks Eddie,
This answer, perhaps supports the clarification for my other thread. _________________ Thanks and Regards
Moorthy |
|
Back to top |
|
|
|