C interoperability and C_LOC intrinsic

David Car david.car7@gmail.com
Sat Sep 18 22:09:00 GMT 2010


I was trying out the ISO_C_BINDINGS module and the use of the C_LOC
intrinsic.  I thought that the standard allowed either an allocatable
or pointer as the argument to C_LOC.  For instance,

program main

  real, allocatable, dimension(:) :: A
  real, pointer, dimension(:) :: p_A

  allocate( A )
  p_A => A

  call my_c_func( c_loc( A ) )
  call my_c_func( c_loc( p_A ) )

  deallocate( A )

end program

The first call to my_c_func works just fine, but the second results in
a compiler error saying that the argument to c_loc "...must be an
associated scalar POINTER".   I tried this with gfortran 4.4 and 4.6
from the svn repo.  Am I misinterpreting the standard?  Thanks.

Regards,

David



More information about the Fortran mailing list