Silverfrost Forums

Welcome to our forums

Passing Common Block from Main to DLLs

20 Dec 2017 7:53 #21021

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!

22 Dec 2017 4:18 #21035

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.

26 Dec 2017 10:14 #21040

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

13 Jan 2018 12:58 #21137

Thanks Eddie,

This answer, perhaps supports the clarification for my other thread.

Please login to reply.