Not really. Even the brand new TS 29113
does not offer a solution. It has the TYPE(*)
but you have to know, how to decode the structure in C. You can do it by reverse engineering.
There is actually a macro for the size of the structure in the referenced TS. See CFI_attribute_allocatable
. But the problem with dereferencing remains. There is a standard array descriptor proposed, but this TS is not yet supported by some compilers (notably by gfortran).
What is possible, is to just pass the pointer to the structure to a generic function such as qsort
. Then you use just a piece of memory, that happens to contain also some pointer or allocatable descriptor, but C does not have to know about them.
Another possibility is to construct a derived type which holds only type(c_ptr)
, instead of Fortran pointers and use c_loc()
to fill them. Be sure to have only contiguous arrays then.