Your C declaration says that you are passing the parameters by value (double jd, as opposed to double *jd or perhaps double &jd in C++). Your Fortran declaration says you are passing the arguments by reference (no VALUE attribute). Never the twain shall meet.
Pick an appropriate parameter/argument passing approach and adjust either the C code or the Fortran declaration to suit (adding VALUE to the Fortran argument declarations would probably be the easiest and most "natural" approach).




C Header file for Fortran DLL using BIND(C)/cdecl and functions returning structs
Okay after working on it over the weekend, I realize that I'm at the limit of my understanding of how to make things interoperable with C specifically in reference to MATLAB. My familiarity with C is passing and this involves things I've never tried to do in C.
I have a series of functions that I have made that are all bind(c) and have a specific user defined type for the return argument. I want the return argument to be flexible, as I want it to be able to return whatever it is the library wants to give it as well as be able to return the error messages/status that are returned.
Here is an example of the user defined type:
The idea is to locally control the valueptr such that all memory gets freed after MATLAB is done with the command.
Here is an example of the function declaration that I want.
I have hacked around trying to get a C header file that would be compatible, and haven't been successful. If someone can help me I'd really appreciate it.
Here is one of the many different header files that I have tried for these:
#define EXPORTED_FUNCTION __declspec(dllexport) #ifdef __cplusplus extern "C" { #endif typedef struct { int ncolumns, nrows, lstring, status; void * valueptr; } c_return; extern "C" __declspec struct c_return c_bodyn(double jd, int is, int ip); #ifdef __cplusplus } #endif