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

Debugging common variables exported from DLL (Fortran 8.1, MSDE 2003)

tashker__michael
Beginner
630 Views
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
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.
So hard to debug code when the debugger lies. Am I missing something

0 Kudos
0 Replies
Reply