- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm creating a shared memory file mapping in a DLL in C++ and assign it to SM01
extern "C" {
__declspec (dllexport) char *SM01 = NULL;
}
I can use this in another C++ DLL by doing this
extern "C" __declspec(dllimport) char *SM01;
#define abc1 (*(int *)(SM01 + 4))
I can assign abc1 to a value in shared memory.
I would like to do the equivalent in a FORTRAN DLL but it's not working. Something like this.
USE, INTRINSIC :: ISO_C_BINDING
IMPLICIT NONE
TYPE(C_PTR), BIND(C) :: SM01
SUBROUTINE FORTRAN_LIBRARY()
INTEGER abc1
EQUIVALENCE (abc1,SM01(4))
abc1 = 555
END
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Wow, thanks for finding that. Maybe that's why the debugger crashes also?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I didn't see a debugger crash using 17.0.2. The type mismatch alone would not do that, but as I noted earlier there had been an issue with REAL(16) variables in the debugger.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
garylscott wrote:Of possible (but remote) interest, here is an easy method of creating a shared memory buffer using file mapping, without need for a DLL. You can share across separate processes (you'll need your own synchronization method, not too hard to do), threads, DLLs, even separate machines with only minor tweaks and additional effort. This was written in ~1999 for DVF or CVF and may need some tweaks for IVF but that should be fairly minor. Overhead will average in the nanoseconds as this prevents page swapping as-is (can be easily changed).
http://www.fortranlib.com/ShareBufferWin32.f90
I could provide an update (IVF compatibility, modernize, etc.) if there's any interest.
Gary,
I am interested in a IVF update to the shared memory example you posted. Thanks in advance.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »