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

What is wrong with this code which gives unresolved external...

TonyRichards
Novice
561 Views

I get an error message as follows:

error LNK2019: unresolved external symbol _ONOWNERDRAW referenced in function _newdlgproc

Here is  the relevant code extract:

INTEGER*4 FUNCTION NewDlgProc(hWnd, mesg, wParam, lParam)
!DEC$ATTRIBUTES STDCALL:: NewDlgProc
!
use dfwin
USE DFLIB
USE OwnerDrawGlobals
!
IMPLICIT NONE

INTEGER*4 hWnd, mesg,lParam, wParam
integer*4 retint
!
INCLUDE 'RESOURCE.FD'
!
Interface
SUBROUTINE OnOwnerDraw(hWnd,ID,hDC)
!DEC$ ATTRIBUTES, STDCALL : : OnOwnerDraw
use DFWINTY
integer(HANDLE) :: hWnd, hDC
integer(DWORD) :: ID
end Subroutine
end interface

...

...

CALL OnOwnerDraw(getdlgItem(hWnd,IDC_OWNER),IDC_OWNER, Itemstruc%Hdc)

 

 

0 Kudos
1 Reply
Ron_Green
Moderator
539 Views

In the source file with 

CALL OnOwnerDraw( .....)

 

You need the INTERFACE copied or included somehow.  each source file with calls to OnOwnerDraw needs to know it's STDCALL, otherwise you'll get the wrong ABI for the call and the link step will fail.  Names for STDCALL procedures are decorated differently.  

Easiest to put OnOwnerDraw into a MODULE and USE the module where you call OnOwnerDraw

 

To elaborate:  if the call is in a subroutine or function:

 

subroutine foo

...

call OnOwnerDraw(...)

end subroutine

 

you need to put the interface inside subroutine FOO.  It does not 'inherit' it from the source file above by magic.

0 Kudos
Reply