passing a fortran int array to C++ by calling C++ function in fortran
- by cppb
hi,
I am trying to call a C++ function in FORTRAN subroutine. This C+ function is supposed to update an integer array. Here is a non-working code I wrote. Can someone please let me know what the issue is:
! FORTRAN function that calls a C++ function
subroutine my_function()
integer(4) ar(*)
integer(4) get_filled_ar
! Need correct syntax here.
ar = get_filled_ar()
end
// C++ function:
extern "C" {
void get_filled_ar(int *ar){
ar[0] = 1;
ar[1] = 10;
ar[3] = 100;
}
}