Xref: utzoo comp.lang.c++:1943 comp.lang.fortran:1492 Path: utzoo!attcan!uunet!mcvax!enea!kth!draken!Urd!newsuser From: newsuser@LTH.Se (LTH network news server) Newsgroups: comp.lang.c++,comp.lang.fortran Subject: Re: f77 and C++ w/ cin/cout: can it be done? Keywords: f77 C++ cin cout printf Message-ID: <1988Nov10.200102.7158@LTH.Se> Date: 10 Nov 88 19:01:01 GMT References: <1118@rivm05.UUCP> Reply-To: dag@Control.LTH.Se (Dag Bruck) Organization: Dept. of Automatic Control, Lund Inst. of Technology, Sweden Lines: 52 In article <1118@rivm05.UUCP> ccea3@rivm05.UUCP (Adri Verhoef) writes: >- I have this fortran-file "m.f": > program main > call hello() > end > >- and I have this C++-file "s.c": >#include >void hello_() >{ > STATEMENTS; >} I have successfully mixed FORTRAN and C++ code. The problem was: 1. The FORTRAN run-time system (including i/o) must be initialized in some way unknown to me. 2. Static constructors must be called in C++ before any of my code. The solution, which may be peculiar to our Silicon Graphics IRIS, is: 1. My FORTRAN ``main'' program calls a C initialization function (reason is exaplained in 2.): PROGRAM MAIN CALL CINIT() ... END 2. The purpose of the C function is to call the C++ initialization function _main(), which is supplied by the compiler. My FORTRAN can't call a subroutine beginning in ``_''. void cinit() { _main(); } I have written no FORTRAN in my application, but I do use a major run-time library written i FORTRAN. The approach above works in my particular application, but I cannot guarantee it will help you. I you *have* to use FORTRAN, good luck -- may the force be with you. Dag Bruck -- Department of Automatic Control Internet: dag@control.lth.se Lund Institute of Technology P. O. Box 118 Phone: +46 46-108779 S-221 00 Lund, SWEDEN Fax: +46 46-138118