PRB: L2029 '_exit' Unresolved External from STOP Stmt in DLLLast reviewed: July 18, 1995Article ID: Q102693 |
The information in the article applies to:
SYMPTOMSAn attempt to link a dynamic-link library (DLL) for the Microsoft Windows operating system fails and Microsoft LINK generates the following message:
error L2029: '_exit' : unresolved external CAUSEMicrosoft FORTRAN does not support using the STOP statement in a DLL developed for Windows.
RESOLUTIONTo terminate the DLL and the calling application, use the SendMessage() function in the Windows application programming interface (API) to send the calling application a WM_QUIT message. The code example below demonstrates this technique.
MORE INFORMATIONThe code example below terminates the DLL and the calling application after displaying a message box warning the user to save all data.
Sample Code - EXIT.FORC Compiler options needed: /c /Od /Zi /AL
interface to integer*2 function PostAppMessage[pascal]
+ (htask, msg, wparam, lparam)
integer*2 htask[value]
integer*2 msg[value]
integer*2 wparam[value]
integer*4 lparam[value]
end
interface to integer*2 function GetCurrentTask[pascal]
end
interface to integer*2 function MessageBox[pascal]
+ (hwnd, boxtext, caption, boxtype)
integer*2 hwnd[value]
character*1 boxtext[reference]
character*1 caption[reference]
integer*2 boxtype[value]
end
subroutine exit
integer*2 in
character buffer1*120, buffer2*80
integer*2 i, WM_QUIT, PostAppMessage, GetCurrentTask, MessageBox
WM_QUIT = #12
buffer1 =
+'************** DLL issued STOP Statement ************'//
+'\n Application will terminate. Save contents of windows NOW'c
buffer2 = 'DLL STOP'c
i = MessageBox(0, buffer1, buffer2, 0)
i = PostAppMessage(GetCurrentTask(), WM_QUIT, in, 0)
return
end
The following QuickWin driver program calls the subroutine in
DLLTEST.FOR.
Sample Code - TEST.FORC Compiler options needed: /c /Od /Zi /MW
program testdllstop
print *, 'before calling DLL'
call dllsub
print *, 'back from sub1'
end
The following DLL displays a dialog box and calls the exit subroutine
to close the DLL and the calling application.
Sample Code - DLLTEST.FORC Compiler options needed: /c /Od /Zi /Aw /Gw
interface to integer*2 function MessageBox[pascal]
+ (hwnd, boxtext, caption, boxtype)
integer*2 hwnd[value]
character*1 boxtext[reference]
character*1 caption[reference]
integer*2 boxtype[value]
end
subroutine dllsub
integer*2 messagebox
i = MessageBox(int2(0), 'Prior to STOP statement in DLL'c,
+ ' 'c, 0)
call exit
end
DLLTEST.DEF
LIBRARY DLLTEST
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS DLLSUB
WEP
MAKEFILEall: test.exe dlltest.dll test.obj: test.for fl /c /Od /Zi /MW test.fordlltest.obj: dlltest.for fl /c /Od /Zi /Aw /Gw dlltest.forexit.obj: exit.for fl /c /Od /Zi /AL exit.fordlltest.dll: dlltest.obj exit.obj link dlltest exit, dlltest.dll, nul, /co /nod ldllfew, dlltest.def;dlltest.lib: dlltest.def implib dlltest.lib dlltest.deftest.exe: test.obj dlltest.lib link test, test, nul, /co /nod llibfew dlltest,
c:\fortran\binb\fl.def;
|
Additional reference words: 5.10
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |