I am creating a C wrapper for an extensive Fortran library algorithms
of which I am not the author.
This Fortran library is made up of multiple modules each containing many global subroutines and variables. Although there are only a handful of user end functions I need, the library is such that it needs to be initialized to set technical parameters before its subroutines can be used. That requires C to be able to access global variables of the Fortran library. Therefore, it seems I need to extern "C"
all these subroutines and variables.
The author of the Fortran library did not use iso_c_binding
but I am able to find all the names of these functions using nm -g algorithms.a
or nm -g algorithms.dylib
. The list is very very long, and it is taking me forever to write:
extern "C" {
int __algorithms_recurse_MOD_accuracy;
int __algorithms_recurse_MOD_precision;
int __algorithms_recurse_MOD_taracc;
void __algorithms_recurse_MOD_optrecurse(int* x, int* y);
// and so on and on...
}
Is there a better strategy than to do this manually? (It's especially time consuming to find out exactly the return types of all these functions).