%VAL() on 64bit Intel64

%VAL() on 64bit Intel64

I have following code


pointer (p1,i1)    ! i1 is only dummy variable

p1=LOC(value)   ! in p1 is address of value

call sub(%VAL(p1))  ! and pass address to routine

subroutine sub(i1)

use ifwinty

integer(LPVOID) i1    ! in i1 should be address of value


end subroutine

It works correctly on win32 architecture but when I tried to compile code for Intel64 I obtained:

error #6633: The type of the actual argument differs from the type of the dummy argument. [%VAL]

So I expect that %VAL is passing only 32bit value instead 64bit value of pointer p1 because subroutine sub parameter i1 is defined as 64bit integer.

My question is how can I find what I am doing wrong.

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

As you must modify it, best change it to use standard Fortran. f2003 came in several years ago.

I tried a test case based on your incomplete paraphrase of the actual code, and it worked fine with generated interface checking. My guess is that your actual code looks different. Please post a small but complete example that demonstrates the problem.

Retired 12/31/2016
Best Reply

What he said:

module resolve

   implicit none

   interface print_kind

      module procedure pk1,pk2,pk4,pk8

   end interface print_kind


      subroutine pk1(x)

         integer(1) x

         write(*,'(a,i0)') 'Kind = ',kind(x)

      end subroutine pk1

      subroutine pk2(x)

         integer(2) x

         write(*,'(a,i0)') 'Kind = ',kind(x)

      end subroutine pk2

      subroutine pk4(x)

         integer(4) x

         write(*,'(a,i0)') 'Kind = ',kind(x)

      end subroutine pk4

      subroutine pk8(x)

         integer(8) x

         write(*,'(a,i0)') 'Kind = ',kind(x)

      end subroutine pk8

end module resolve
program test

   use resolve

   use ifwin

   implicit none

   integer i1


   integer, target :: value

   p1 = LOC(value)

   call print_kind(%val(p1))

   write(*,'(a,i0)') 'LPVOID = ',LPVOID

end program test

Kind = 8


Thanks for code example.

I have found problem. My code is more complicated that I previously posted:


    pointer (p1,i1)    ! i1 is only dummy variable

    character*10 name

    integer*4 iLen

    p1=LOC(name)   ! in p1 is address of value  

    call sub(%VAL(p1),...,%VAL(iLen))  ! and pass address to routine , length of character last and by value

    subroutine sub(i1,....,i7)

    use ifwinty

    integer(LPVOID) i1    ! in i1 should be address of value


    integer(LPVOID) i7


    end subroutine  

and problem is caused by length of string passed as last parameter because %VAL(iLen) is integer*4 (32 bit) and not INTEGER(HANDLE) (64bit)

So i will need to modify my routine "sub" which I use to call functions from external dll in this specific case.

I am sorry to disturb You.

Leave a Comment

Please sign in to add a comment. Not a member? Join today