Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!csus.edu!ucdavis!csusac!unify!Unify.com!grp From: grp@Unify.com (Greg Pasquariello) Newsgroups: comp.lang.c++ Subject: Re: bug with making C++ functions have C linkage ? Message-ID: <1991Apr22.081254@Unify.com> Date: 22 Apr 91 15:12:54 GMT References: <1991Apr16.122905.23613@cs.nott.ac.uk> <675@taumet.com> Sender: news@Unify.Com (news admin) Reply-To: grp@Unify.com (Greg Pasquariello) Organization: Unify Corporation, Sacramento, CA, USA Lines: 32 In article <675@taumet.com>, steve@taumet.com (Stephen Clamage) writes: > > Almost all current C++ compilers require that main() be compiled by > the C++ compiler, even if other modules are compiled with a compatbile > C compiler. Your compiler manual should tell you this. > > In general, C++ programs will require initialization of static objects > via their constructors at runtime; cout is such an object. The C++ > compiler arranges for the constructors (and destructors) to be called > via special code emitted in the module in which main() appears. This > ensures the special code is emitted and called exactly once. Only if some objects need initialization, and cannot provide it themselves! Iostreams with 2.0 provide an initializer object, called Iostream_init, so there is no reason you cannot use it unless you don't have the iostream library or a similar method of initializing your objects. It's true, I read it in the manual! :-) > > In your example, main() was not compiled by the C++ compiler, cout > was not initialized, and the program failed when it tried to use > member functions of cout. > -- > > Steve Clamage, TauMetric Corp, steve@taumet.com -- --- Greg Pasquariello grp@unify.com Unify Corporation Be good and never poison people