Path: utzoo!attcan!uunet!dino!ux1.cso.uiuc.edu!uwm.edu!lll-winken!muslix.llnl.gov!jac From: jac@muslix.llnl.gov (James Crotinger) Newsgroups: comp.lang.c++ Subject: Re: How to call C++ functions from Fortran with C++ 2.0 Message-ID: <52273@lll-winken.LLNL.GOV> Date: 14 Mar 90 20:00:16 GMT References: <1990Mar13.172657.277@sdr.slb.com> Sender: usenet@lll-winken.LLNL.GOV Reply-To: jac@muslix.llnl.gov.UUCP (James Crotinger) Organization: Lawrence Livermore National Laboratory/UC Davis Lines: 35 Another approach would be to make square() and 'extern "C"' function. For instance: extern "C" void SQUARE(int *i, int*j); void SQUARE(int *i, int *j) { *j = *i * *i; } In fortran this would be called simply as: call square(i,j) BTW, you're example used references for i and j. I would think that this, too, might be very implementation dependent. I don't believe that there is any gaurantee in the language that a function which takes a reference actually work as though it takes a pointer. Also, you translated the name to lower case: char square__FRiT1 (__0i , __0j ) ==> char square__frit1_ (__0i , __0j ) If this isn't incorrect, it is at least system dependent as fortran symbols are supposed to be presented to the linker in upper case. Of course what there should be is 'extern "FORTRAN"' statement which would handle not only name demangling, but also would get the case correct for whatever system you happen to be running on and would also allow proper use of references. Jim