https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84885

--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Thu, Mar 15, 2018 at 09:57:08PM +0000, mdblack98 at yahoo dot com wrote:
> 
> --- Comment #3 from mdblack98 at yahoo dot com ---
> I'll correct my reply in that using len > 1 outside of an interoperability
> block is OK.
> 
> So it is apparently now impossible to declare c_char len > 1 inside such a
> block?
> 

Steve Lionel is correct.  If you have a BIND(C) entity
and it involves the character type, then the length
parameter must be 1.  I quoted from a draft of the
upcoming F2018, because that is what I had at hand.  The
Fortran 2003 standard has essentially the same language:

F2003, page 398

   A Fortran derived type is interoperable with a C
   struct type if the derived-type definition of the Fortran
   type specifies BIND(C) (4.5.1), the Fortran derived type
   and the C struct type have the same number of components,
   and the components of the Fortran derived type have types
   and type parameters that are interoperable with the types
   of the corresponding components of the struct type.

Fortran 2003, page 396

   ...; if the type is character, interoperability also requires
   that the length type parameter be omitted or be specified
   by an initialization expression whose value is one.

You can specify an array of characters, e.g.,

type, bind(c) :: foo
   character(kind=c_char, len=1) :: c(10)
end type foo

PS: The name of the language is Fortran.  It hasn't been
written in all capital letters since 1990.

Reply via email to