This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
IMPORT or C Binding bug?
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: fortran at gcc dot gnu dot org
- Date: Thu, 28 Jun 2007 13:59:56 -0700
- Subject: IMPORT or C Binding bug?
In trying to compile some real world code with Chris'
ISO C Binding patch, I ran into the following code:
module pthreads
use, intrinsic :: iso_c_binding
implicit none
private
save
type, bind( c) :: pthread_t
private
integer(kind=c_int), dimension(2) :: secret
end type pthread_t
interface
!
! This works.
!
type(pthread_t) function pthread_testcancel( ) bind(c)
import :: pthread_t
end function pthread_testcancel
!
! This fails!
!
! integer(kind=c_int) function pthread_cond_init(cond, attr) bind(c)
! import :: c_ptr, c_int
! type(c_ptr), value :: cond
! type(c_ptr), value :: attr
! end function pthread_cond_init
function pthread_cond_init(cond, attr) bind(c)
import :: c_ptr, c_int
integer(kind=c_int) pthread_cond_init
type(c_ptr), value :: cond
type(c_ptr), value :: attr
end function pthread_cond_init
end interface
end module pthreads
Should the code marked 'This fails!' actually compile? Note that
'import(pthread_t)' works in the previous interface. If I re-arrange
the code as in the last interface, the 'import :: c_int' appears
to correctly pick up the correct value.
--
Steve