- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following is straight out of the Fortran help system, about sharing common block variables between a program and a DLL:
MAIN PROGRAM:
PROGRAM COMMONX
!DEC$ ATTRIBUTES DLLIMPORT:: SETA, /X/
COMMON /X/ C, B, A
REAL C, B, A, Q
EQUIVALENCE (A,Q)
A = 0.
I = 0
WRITE (6,*) 'In Main program before calling SETA...'
WRITE (6,*) 'values of A and I:' , A, I
CALL SETA(I)
WRITE (6,*) 'In Main program after calling SETA...'
WRITE (6,*) 'values of A and I:' , Q, I
A = A + 1.
I = I + 1
WRITE (6,*) 'In Main program after incrementing values'
END PROGRAM COMMONX
ROUTINE IN DLL:
SUBROUTINE SETA(I)
!DEC$ ATTRIBUTES DLLEXPORT :: SETA, /X/
COMMON /X/ C, B, A
REAL C, B, A
INTEGER I
A = A + 1.
I = I + 1
WRITE (6,*) 'In SETA subroutine, values of A and I:' , A, I
RETURN
END SUBROUTINE
!DEC$ ATTRIBUTES DLLEXPORT :: SETA, /X/
COMMON /X/ C, B, A
REAL C, B, A
INTEGER I
A = A + 1.
I = I + 1
WRITE (6,*) 'In SETA subroutine, values of A and I:' , A, I
RETURN
END SUBROUTINE
Running this program produces expected and correct results. However, looking at the common variables in the debugger does not. In the SETA context all is well, but in the main program all the common variables display
as garbage both before and after the call to SETA. That's true in a watch window, the command window, the locals window or tooltip. The debugger apparently doesn't know about vars in DLLIMORTed common blocks.
as garbage both before and after the call to SETA. That's true in a watch window, the command window, the locals window or tooltip. The debugger apparently doesn't know about vars in DLLIMORTed common blocks.
So hard to debug code when the debugger lies. Am I missing something
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page