<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Function Pointers in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954870#M20522</link>
    <description>Did you try this? Surely LOC(MyWindowProc) is the name of an internal procedure which (%)LOC doesn't allow? &lt;BR /&gt; &lt;BR /&gt;-- &lt;BR /&gt;Gerry T.</description>
    <pubDate>Tue, 19 Jun 2001 01:46:19 GMT</pubDate>
    <dc:creator>Intel_C_Intel</dc:creator>
    <dc:date>2001-06-19T01:46:19Z</dc:date>
    <item>
      <title>Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954867#M20519</link>
      <description>Several Windows API's require the address of a function (MyFunc, say) as input. As far as I can make out, the rules-of-behavior of CVF's (%)Loc extension in conjunction with use of integer (Cray-style) pointers prohibit passing the address of MyFunc. The only way around that I can conjur up is that if MyFunc is in a MyDLL then its address is GetProcAddress(LoadLibrary('MyDLL'C),'MyFunc'C) assuming MyFunc is an export. But if I don't want to export MyFunc, what's my alternative? Does F2K's interoperability-with-C impact on what I'm trying to do? &lt;BR /&gt; &lt;BR /&gt;Thanks, &lt;BR /&gt;Gerry T.</description>
      <pubDate>Tue, 19 Jun 2001 00:40:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954867#M20519</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-06-19T00:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954868#M20520</link>
      <description>Not 100% sure to me what you're trying to do. Nothing prohibits &lt;BR /&gt;you from using LOC() on an &lt;B&gt;existing&lt;/B&gt; function, for example &lt;BR /&gt;when subclassing a window: &lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt;&lt;FONT size="+0"&gt; 
lpfnOldWindowProc=SetWindowLong(hWnd, GWL_WNDPROC, LOC(MyWindowProc)) 
&lt;/FONT&gt;&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;If your function is pointee of an integer-pointer, simply pass &lt;BR /&gt;the integer pointer once it receives a valid value. Thus, you don't &lt;BR /&gt;need mesing with DLLs.&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;Or am I missing something? &lt;BR /&gt; &lt;BR /&gt;Jugoslav</description>
      <pubDate>Tue, 19 Jun 2001 01:06:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954868#M20520</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2001-06-19T01:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954869#M20521</link>
      <description>Right - as long as CVF knows it's a procedure (either there's an INTERFACE or an EXTERNAL declaration), you can pass LOC(routine), if the argument is declared as an integer.  If the Fortran INTERFACE declared the argument as a procedure, then pass the procedure name directly (not an issue with Win32 API routines).&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 19 Jun 2001 01:42:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954869#M20521</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-06-19T01:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954870#M20522</link>
      <description>Did you try this? Surely LOC(MyWindowProc) is the name of an internal procedure which (%)LOC doesn't allow? &lt;BR /&gt; &lt;BR /&gt;-- &lt;BR /&gt;Gerry T.</description>
      <pubDate>Tue, 19 Jun 2001 01:46:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954870#M20522</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-06-19T01:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954871#M20523</link>
      <description>I want to call SetConsoleCtrlHandler as interfaced in kernel32.  &lt;BR /&gt;  &lt;BR /&gt;&lt;IN an="" all="" fortran="" version="" of="" a="" cvf="" dll=""&gt;  &lt;BR /&gt;the code snippet   &lt;BR /&gt;  &lt;BR /&gt;&lt;FONT size="+1"&gt;&lt;PRE&gt;
:  
interface   
subroutine SetCtrlHandler(hConOut)  
integer hConOut  
end subroutine SetCtrlHandler  
end interface  
call SetCtrlHandler(hwnd)  
:  
:  
logical(4) function handler(dwCtrlType)  
:  
!Success  
handler = 1  
return  
end function handler  
  
subroutine SetCtrlHandler(hConOut)  
  
use dfwinty  
use kernel32, only: SetConsoleCtrlHandler  
  
implicit none  
  
interface  
logical(4) function MyHandler(hConOut)  
integer hConOut  
end function MyHandler  
end interface  
  
external handler  
pointer(ptr_handler,MyHandler)  
integer hConOut  
logical(4) status  
integer, external :: MyHandler  
ptr_handler = Loc(handler)  
status = SetConsoleCtrlHandler(Myhandler,.true.)  
  
end subroutine SetCtrlHandler  
&lt;/PRE&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;IN a="" fortran=""&gt;  &lt;BR /&gt;the equivalent code snippet is  &lt;BR /&gt;  &lt;BR /&gt;&lt;FONT size="+1"&gt;&lt;PRE&gt;
:  
interface   
subroutine SetCtrlHandler[C,ALIAS:'_SetCtrlHandler'] (hConOut)  
integer hConOut  
end subroutine SetCtrlHandler  
end interface  
call SetCtrlHandler(hwnd)  
:  
:  
#include &lt;WINDOWS.H&gt;  
#include &lt;STRING.H&gt;  
#include &lt;CONIO.H&gt;  
  
BOOL WINAPI handler(DWORD dwCtrlType)  
{  
:  
	return(TRUE);  
}  
  
void SetCtrlHandler(HANDLE hConOut)  
{  
  BOOL status;  
  
  //Set custom handler for process  
  status = SetConsoleCtrlHandler(handler, TRUE);  
      
  return;  
}  
&lt;/CONIO.H&gt;&lt;/STRING.H&gt;&lt;/WINDOWS.H&gt;&lt;/PRE&gt;&lt;/FONT&gt;&lt;BR /&gt;  &lt;BR /&gt;This Fortran/C version works (and so does the handler) but the all Fortran version doesn't even compile due to 1 or 2 errors, viz:  &lt;BR /&gt;1. at the statement  &lt;BR /&gt;integer, external :: MyHandler  &lt;BR /&gt;Error: This name has already been used as an external procedure name.   [MYHANDLER]  &lt;BR /&gt;2. at the statement  &lt;BR /&gt;status = SetConsoleCtrlHandler(Myhandler,.true.)  &lt;BR /&gt;Error: This actual argument must not be the name of a procedure.   [MYHANDLER]  &lt;BR /&gt;  &lt;BR /&gt;If I remove the interface to MyHandler, the first error goes away and the secord error changes to  &lt;BR /&gt;Error: This actual argument must not be the name of a procedure.   [MYHANDLER]  &lt;BR /&gt;  &lt;BR /&gt;Can someone kindly tell me what's wrong with the all Fortran version?  &lt;BR /&gt;  &lt;BR /&gt;Thanks,  &lt;BR /&gt;Gerry T.&lt;/IN&gt;&lt;/IN&gt;</description>
      <pubDate>Tue, 19 Jun 2001 03:42:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954871#M20523</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-06-19T03:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954872#M20524</link>
      <description>The interface block defines MyHandler, so your EXTERNAL declaration is redundant.  Remove it.  Use loc(MyHandler) in the call to SetConsoleCtrlHandler.&lt;BR /&gt;&lt;BR /&gt;Warning - this code may not work correctly unless you compile with /fpscomp:logicals.  CVF LOGICAL is not the same as C BOOLEAN, which is what the Win32 API uses.  I suggest making MyHandler INTEGER instead of LOGICAL and passing TRUE (from DFWINTY) instead of .TRUE. - these are different values.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 19 Jun 2001 03:57:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954872#M20524</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-06-19T03:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Function Pointers</title>
      <link>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954873#M20525</link>
      <description>Excellent. Thanks Steve and Jugoslav. Now the all Fortran version works and so does the handler. &lt;BR /&gt; &lt;BR /&gt;Ciao, &lt;BR /&gt;Gerry T.</description>
      <pubDate>Tue, 19 Jun 2001 04:12:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Function-Pointers/m-p/954873#M20525</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-06-19T04:12:41Z</dc:date>
    </item>
  </channel>
</rss>

