PROGRAM tt USE ISO_C_BINDING, ONLY : C_INTPTR_T, C_LOC USE IFWIN, ONLY : LPVOID, NULL IMPLICIT none ! TYPE :: mytype INTEGER :: i, j, k END TYPE mytype TYPE(mytype) :: mt ! write(*,*) 'The value of LPVOID: ', LPVOID write(*,*) 'The value of C_INTPTR_T: ', C_INTPTR_T write(*,*) 'The kind value of 0_C_INTPTR_T:', KIND(0_C_INTPTR_T) write(*,*) 'The kind value of NULL: ', KIND(NULL) write(*,*) ! mt = mytype(4,5,6) ! write(*,'(a,i16)') ' The value of LOC(MT): ',LOC(mt) write(*,*) ! ! the use of TRANSFER(C_LOC(mt),0_C_INTPTR_T) gives a result that equals LOC(mt) ! write(*,'(a,i16)') ' The value of TRANSFER(C_LOC(mt),0_C_INTPTR_T):',TRANSFER(C_LOC(mt),0_C_INTPTR_T) write(*,'(a,z16.16)') ' The hex value of that TRANSFER ',TRANSFER(C_LOC(mt),0_C_INTPTR_T) write(*,'(a,i16)') ' The kind value of that TRANSFER ',KIND(TRANSFER(C_LOC(mt),0_C_INTPTR_T)) write(*,*) ! ! the use of TRANSFER(C_LOC(mt),NULL) went wrong under 64 bit ! write(*,'(a,i16)') ' The value of TRANSFER(C_LOC(mt),NULL): ',TRANSFER(C_LOC(mt),NULL) write(*,'(a,z16.16)') ' The hex value of that TRANSFER ',TRANSFER(C_LOC(mt),NULL) write(*,'(a,i16)') ' The kind value of that TRANSFER ',KIND(TRANSFER(C_LOC(mt),NULL)) ! STOP END PROGRAM tt