How to call a void *function(...)
from Fortran?
I am currently trying to call a few C functions from Fortran. I have done so before, but I have called only my own functions. For example, to call:
void add(int *csum, int *ca, int *cb) { *csum = *ca + *cb; }
from Fortran, I have used:
INTEGER :: fsum, fa, fb
CALL add(fsum, fa, fb)
This works fine. Now I have a couple of functions roughly like:
void *create_obj(void);
void use_obj(void *obj);
void free_obj(void *obj);
or even:
struct private_struct; /* defined somewhere else */
struct private_struct *create_p(void);
void use_p(struct private_struct *p);
void free_f(struct private_struct *p);
where the struct is private, i.e., I have no knowledge of its members.
Question: How can I get the return values into Fortran? I do not really need to access them, but I must store them somehow during their create
...use
...destroy
lifecycle.