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

RaiseException() WinAPI - last argument

Nick2
New Contributor I
1,609 Views

I'm trying to use the function RaiseException(). I'm having trouble sending in the last argument...what is the correct way to send it in?

 

[fxfortran]      USE KERNEL32
      USE IFWINTY

      TYPE(T_EXCEPTION_RECORD) xr
      INTEGER(ULONG_PTR) lpArguments

      xr%ExceptionInformation(1)=696969
      xr%ExceptionInformation(2)=333333
      xr%ExceptionInformation(3)=777777
      lpArguments=%LOC(xr%ExceptionInformation)
      CALL RaiseException(1,0,3,lpArguments)[/fxfortran]

 


If I get rid of the lpArguments variable

 

 

 

 

[fxfortran]      CALL RaiseException(1,0,3,xr%ExceptionInformation)[/fxfortran]


I get this error:

error #6634: The shape matching rules of actual arguments and dummy arguments have been violated. [EXCEPTIONINFORMATION]

 

 

 

0 Kudos
1 Solution
Steven_L_Intel1
Employee
1,609 Views
I think the fourth argument is incorrectly declared in module KERNEL32. It looks to me as if someone started to define it correctly, but did only half the job.

See if the following declaration works for you.

[fortran]INTERFACE 
   SUBROUTINE RaiseException( &
        dwExceptionCode, &
        dwExceptionFlags, &
        nNumberOfArguments, &
        lpArguments)
import
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'RaiseException' :: RaiseException
  integer(DWORD) dwExceptionCode ! DWORD dwExceptionCode
  integer(DWORD) dwExceptionFlags ! DWORD dwExceptionFlags
  integer(DWORD) nNumberOfArguments ! DWORD nNumberOfArguments
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL, IGNORE_LOC :: lpArguments
  integer(ULONG_PTR), dimension(*) :: lpArguments ! ULONG_PTR* lpArguments
 END SUBROUTINE
END INTERFACE[/fortran]

The lpArguments argument is an array of pointer-sized arguments. If you use the above as-is, you'll need to rename away the matching definition from KERNEL32. Alternatively, you can change the local name of the subroutine in this interface and use the changed name.

View solution in original post

0 Kudos
3 Replies
Xiaoping_D_Intel
Employee
1,609 Views
The last argument of "RaiseException" was declared as below in "include\kernel32.f90":

!DEC$ ATTRIBUTES REFERENCE, IGNORE_LOC :: lpArguments
integer(ULONG_PTR) lpArguments ! ULONG_PTR* lpArguments

It is the reference of the exception arguments array. In this case it can be called as:

CALLRaiseException(1,0,3,xr%ExceptionInformation(1))




0 Kudos
Steven_L_Intel1
Employee
1,610 Views
I think the fourth argument is incorrectly declared in module KERNEL32. It looks to me as if someone started to define it correctly, but did only half the job.

See if the following declaration works for you.

[fortran]INTERFACE 
   SUBROUTINE RaiseException( &
        dwExceptionCode, &
        dwExceptionFlags, &
        nNumberOfArguments, &
        lpArguments)
import
    !DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'RaiseException' :: RaiseException
  integer(DWORD) dwExceptionCode ! DWORD dwExceptionCode
  integer(DWORD) dwExceptionFlags ! DWORD dwExceptionFlags
  integer(DWORD) nNumberOfArguments ! DWORD nNumberOfArguments
!DEC$ ATTRIBUTES REFERENCE, ALLOW_NULL, IGNORE_LOC :: lpArguments
  integer(ULONG_PTR), dimension(*) :: lpArguments ! ULONG_PTR* lpArguments
 END SUBROUTINE
END INTERFACE[/fortran]

The lpArguments argument is an array of pointer-sized arguments. If you use the above as-is, you'll need to rename away the matching definition from KERNEL32. Alternatively, you can change the local name of the subroutine in this interface and use the changed name.
0 Kudos
Nick2
New Contributor I
1,609 Views
That's what I was missing! It worked either way, I'll put a TODO note to check if they change that in a future version of IVF.
0 Kudos
Reply