Calling C++ from Fortran

Thanks. I have been looking at your example of Fortran calling C++ stdlib sort routines.

Regarding your suggestion to use [] rather than * for arrays in prototypes,

gfortran -fc-prototypes -c sum_vec.f90

on

module m
use iso_c_binding
implicit none
contains
subroutine sum_vec(n,x,xsum) bind(c)
integer(kind=c_int)  , intent(in)  :: n
real   (kind=c_float), intent(in)  :: x(n)
real   (kind=c_float), intent(out) :: xsum
xsum = sum(x)
end subroutine sum_vec
end module m

generates a prototype

void sum_vec (const int *n, const float *x, float *xsum);

but this can be adjusted manually to

void sum_vec (const int *n, const float x[], float *xsum);