C, Fortran, and single-character strings

C, Fortran, and single-character strings

A problem of the latter variety recently turned up in how some C programs are passing strings to Fortran subroutines, with unpleasant effects on widely used packages like LAPACK

The C language famously does not worry much about the length of strings, which simply extend until the null byte at the end. When strings are passed as arguments to functions or subroutines, the GCC Fortran argument-passing conventions state that the length of each string is to be appended to the list of arguments. The C compiler will do no such thing, though, so the proper call to that function from C would look like:

From C, the length of must be passed explicitly the end of the list of arguments.

Source: lwn.net