Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!rutgers!husc6!ut-sally!seismo!sundc!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c++ Subject: Re: Standard C routines calling C++ (non-member) functions Message-ID: <586@hadron.UUCP> Date: Wed, 1-Oct-86 10:11:42 EDT Article-I.D.: hadron.586 Posted: Wed Oct 1 10:11:42 1986 Date-Received: Sat, 4-Oct-86 12:06:41 EDT References: <6059@alice.uUCp> <1221@uw-june> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 24 Summary: Calling C++ from C ... In article <1221@uw-june> brian@uw-june.UUCP (Brian Bershad) writes: >> More annoyingly, the following core dumps in ostream... >> void foo(int* x, int* y) ... >> when it is called from a C program (for reasons that are beyond >BS's response: >>>I conjecture that you did not load the program using CC so that the constructors >>>initializing cin, cout, and cerr were not called. A similar effect (core dump >>>on the first C++ stream I/O operation) can be obtained by not compiling main() >>>by CC. >You got it. >Yes, they were loaded properly. >The problem seems to only happen when you call a C++ function from >standard C main(). If I reverse the calling sequence, things work. >I guess, in retrospect, this makes sense. In the C++ that I installed, there is a clearly defined procedure to make C++ run from C. One must call a certain routine from main() before calling any C++. It is not in the book, so it must be in the installation instructions (which I do not have near me). Check there. -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP} jsdy@hadron.COM (not yet domainised)