Compilers supporting generation of C function prototypes

I’m not sure this works as expected. With my gfortran 15.1.0, the code:

program test

use iso_c_binding
implicit none

interface
  function my_c_function(string) bind(c)
    import :: c_int, c_char
    integer(c_int) my_c_function
    character(kind=c_char, len=*) string
  end function
end interface

end program

generates:

#include <stddef.h>
#ifdef __cplusplus
#include <complex>
#define __GFORTRAN_FLOAT_COMPLEX std::complex<float>
#define __GFORTRAN_DOUBLE_COMPLEX std::complex<double>
#define __GFORTRAN_LONG_DOUBLE_COMPLEX std::complex<long double>
extern "C" {
#else
#define __GFORTRAN_FLOAT_COMPLEX float _Complex
#define __GFORTRAN_DOUBLE_COMPLEX double _Complex
#define __GFORTRAN_LONG_DOUBLE_COMPLEX long double _Complex
#endif

int my_c_function (char *string);

#ifdef __cplusplus
}
#endif

I was expecting:

int my_c_function(CFI_cdesc_t *string);

Unless I’m still missing something about C/Fortran interoperability :slight_smile: