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

beginthreadex FORTRAN interface

ZlamalJakub
New Contributor III
939 Views

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 Kudos
5 Replies
Steven_L_Intel1
Employee
939 Views

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

0 Kudos
Paul_Curtis
Valued Contributor I
939 Views

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]

0 Kudos
ZlamalJakub
New Contributor III
939 Views

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?

0 Kudos
jimdempseyatthecove
Honored Contributor III
939 Views

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

0 Kudos
Steven_L_Intel1
Employee
939 Views

Use this instead:

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

0 Kudos
Reply