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

Opening I/O files from main program, writing to them from .DLL

Pellegrini__Etienne
369 Views

Hello,

I'm experiencing similar problems to that of https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/272906

When opening a file with a specified unit number in the main program, and then writing to this unit number from a .dll, a new fort.unitNumber file is created. I can not use the solution provided in the above mentioned forum thread, because my main program is a quickwin application, and that using the /libs:dll compiler option breaks the references to any of the quickWin routines. Similarly, I cannot choose \libs:qwin for my dlls.

Is there a way around this problem? Or is writing to already opened files from a .dll not possible when creating a qwin application?

Thank you very much,

Etienne

0 Kudos
4 Replies
Steven_L_Intel1
Employee
369 Views

Sorry, your use of QuickWin makes this not possible.

Perhaps you could pass into the DLL a procedure from your main program that the DLL would call to do I/O? I don't know what the full structure of your program is like.

Is there really a need to use a DLL rather than a static library?

0 Kudos
Pellegrini__Etienne
369 Views

I do need a DLL rather than a static library: I want the DLL to be able to change regularly without recompiling the main program.

As for passing into the DLL a procedure from the main program, I would actually have to pass it as an argument to one of the DLL's subroutines? I didn't think I could call a procedure defined in the main program from the DLL, as this seems to introduce circular dependencies.

0 Kudos
Steven_L_Intel1
Employee
369 Views

Yes, you would pass it as an argument. It's not a link dependency.

If this is something you did a lot, you could keep a set of procedure pointers in the DLL that did the various I/O functions and call an "initialization" routine at the start of the EXE into the DLL to pass the various procedures that it would then save pointers to.

0 Kudos
Pellegrini__Etienne
369 Views

Thank you Steve, the pointers solution works and is elegant!

Thanks
Etienne

 

0 Kudos
Reply