Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29250 ディスカッション

beginthreadex FORTRAN interface

ZlamalJakub
新規コントリビューター III
954件の閲覧回数

I am converting my win32 application to 64bit version and I have problem with beginthreadex function. Interface for this function is not present in IVF include files.

Where I can find interface for this function?

 

0 件の賞賛
5 返答(返信)
Steven_L_Intel1
従業員
954件の閲覧回数

This is a MSVC library routine, with special hooks into the MSVC runtime, not a Windows API routine.Use CreateThread.

Paul_Curtis
高評価コントリビューター I
954件の閲覧回数

try this:

[fortran]

! Interfaces to Microsoft Visual C library thread routines
! Must link against multithreaded libraries
interface
  function $beginthreadex (security, stack_size, start_address, arglist, &
                           initflag, thrdaddr)
  use ifwinty
  integer(UINT) :: $beginthreadex
  !DEC$ ATTRIBUTES C, alias:"__beginthreadex" :: $beginthreadex
  type(T_SECURITY_DESCRIPTOR), intent(IN) :: security
  !DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL :: security
  integer(UINT),  intent(IN) :: stack_size
  integer(PVOID), intent(IN) :: start_address  ! Must be STDCALL calling     was (PVOID)
                                               ! mechanism, 1 arg
  integer(PVOID), intent(IN) :: arglist
  integer(UINT),  intent(IN) :: initflag
  integer(UINT),  intent(OUT):: thrdaddr
  !DEC$ ATTRIBUTES REFERENCE,IGNORE_LOC :: thrdaddr
  end function $beginthreadex
end interface

 

[/fortran]

ZlamalJakub
新規コントリビューター III
954件の閲覧回数

To Steve Lionel: Thanks for response I expected it is API function. Now I understand why it is not part of IVF headers.

To Paul Curtis: Thanks for Your example. I already use very similar interface, but it seems to work only for win32. When I compile my code for x64 I obtain error:

error LNK2019: unresolved external symbol __beginthreadex referenced in function xxx

I suppose problem is in two initial underscores. I am little bit confused in naming conventions of x64.

You have no problems to compile x64 with Yours interface?

jimdempseyatthecove
名誉コントリビューター III
954件の閲覧回数

The following is from old code and "works" but should be updated to use the inter-operational feature for DWORD

! use ControlPanel as thread_func
integer(INT_PTR_KIND()) :: ControlPanelArg = 0
integer(4) :: ControlPanelFlags = 0
integer(INT_PTR_KIND()) :: ControlPanelThread_ID = 0
INTERFACE
  integer(4) FUNCTION ControlPanel(arg)
    !DEC$ ATTRIBUTES STDCALL, ALIAS:"_controlpanel" :: ControlPanel
    integer(4),POINTER :: arg
  END FUNCTION
END INTERFACE
...................
! Create seperate thread to run the Modal Dialog control pannel
ControlPanelHandle = CreateThread(&
& NULL, ControlPanelStack, loc(ControlPanel), loc(ControlPanelArg), ControlPanelFlags, loc(ControlPanelThread_ID))
......................
integer(4) FUNCTION ControlPanel(arg)
!DEC$ ATTRIBUTES STDCALL, ALIAS:"_controlpanel" :: ControlPanel
  USE IFLOGM
  use   GlobalData
  implicit none
  INCLUDE 'RESOURCE.FD'
  integer(4),POINTER :: arg
.......

Jim Dempsey

Steven_L_Intel1
従業員
954件の閲覧回数

Use this instead:

!DEC$ ATTRIBUTES C, DECORATE, alias:"_beginthreadex" :: $beginthreadex

返信