Does
character(kind-c_char,len=1) c(10)
work for your application? C “strings” differ from Fortran character with len > 1 in that the C strings have an extra NULL character tacked on the end.
Cheers,
Bill
> On Mar 15, 2018, at 5:41 PM, Black Michael <[log in to unmask]> wrote:
>
> We have some code that uses c_char with gcc like the code beloiw to receive char strings from C. This is in WSJT-X...a very popular ham radio program.
> It has compiled fine with gcc for years.
> Now..with gcc-8.0 it won't compile since len>1 is not one of the iso_c_binding types. This means we will have to rewrite code and this becomes MUCH harder to do using a shared memory structure across the C/FORTRAN boundary we have.
> Any thoughts?
>
>
> subroutine foo(i,c)
> use, intrinsic :: iso_c_binding, only: c_char
> integer i
>
> type, bind(C) :: params_block
> character(kind=c_char,len=10) :: c
> end type params_block
> write(*,*) 'X',c,'Z'
> end
>
>
>
> -----------------------------------
> Michael D. Black
Bill Long [log in to unmask]
Principal Engineer, Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9143
Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
|