We are having a problem to match properly a C++ struct exported as dll using GNU g++ 4.4.0 with a COMMON block in Fortran using GNU gfortran 4.4.0. Tt works properly in Linux version, but not with Mingw. Probably we are missing something in this platform. Any help will be welcomme.
Code in C++ (compiled as a dll): extern "C" { extern struct { int n; int k; } area_ ; } extern "C" __declspec(dllexport) void view_() { area_.n= 83; printf("c ++, n=%d , k=%d \n",area_.n,area_.k); return; } Code in FORTRAN (main program calling the previous dll): BLOCK DATA t INTEGER N,K COMMON /AREA/ N,K END PROGRAM P456 COMMON /AREA/ N,K N = 3 K = 6 WRITE(*,*) N,K CALL view WRITE(*,*) N,K END PROGRAM We add an extra C file to the dll for compiling independly of FORTRAN: __declspec(dllexport) struct { int n; int k; } area_ ; Using GNU g++ and gfortran in Mingw the area_ struct is not properly shared and two copies are used in memory, the output is wrong: 3 6 83 0 3 6 But using GNU g++ and gfortran 4.4 in Linux Debian and Microsoft C++ 6.0, 2003 and 2008 we obtain a correct result: 3 6 83 6 83 6 The AREA common block in FORTRAN does not point to the same struct area in C++ dll, why? Why fails only in Windows platform using GNU C++ compiler? Thanks for any help Pedro _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus