------- Comment #1 from burnus at gcc dot gnu dot org 2008-03-30 13:40 ------- CLOSED AS INVALID.
> return type of complex functions not C compatible While (with the default options) Fortran should be compatible with C in this case, the proper way would be to use Fortran 2003's BIND(C) features: function foo() bind(C) use iso_c_binding complex(c_double) :: foo However, the problem lies on the C side of your program. First, I note that you should not use a struct for complex but use the complex data type of C99 otherwise the program may fail on some systems. In any case, the following C program works flawlessly here using your Fortran code: ---------------------------------- #include <complex.h> #include <stdio.h> float complex fcomplex_func_(int *); double complex dcomplex_func_(int *); int main() { float complex f; double complex d; int i; i = 12; f = fcomplex_func_(&i); printf("%f + I*%f\n", __real__ f, __imag__ f); i = 13; d = dcomplex_func_(&i); printf("%f + I*%f\n", __real__ d, __imag__ d); return 0; } ---------------------------------- Regarding your code: If not really needed, I strongly suggest that you never use -ff2c; this option causes lot of unexpected things, does not work well with newer Fortran features (such as BIND(C)) and is not so well tested. #ifdef FF2C extern fcomplex fcomplex_func__(int const *); extern dcomplex dcomplex_func__(int const *); #else extern void fcomplex_func_(fcomplex *, int const *); extern void dcomplex_func_(dcomplex *, int const *); #endif Please change "ifdef" into "ifndef" and change "__" into "_" and vise versa. You seemingly mixed up the definition of -ff2c and -fno-f2c. After these changes your program works for me using both -ff2c -DFF2C=1 and with the default options. -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35765