Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!dataio!fnx!nazgul!bright From: bright@nazgul.UUCP (Walter Bright) Newsgroups: comp.lang.c++ Subject: Re: bug with making C++ functions have C linkage ? Message-ID: <306@nazgul.UUCP> Date: 26 Apr 91 17:16:18 GMT References: <1991Apr16.122905.23613@cs.nott.ac.uk> <675@taumet.com> <1991Apr22.081254@Unify.com> Reply-To: bright@nazgul.UUCP (Walter Bright) Organization: Zortech, Seattle Lines: 14 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. / / 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 is not the way Zortech C/C++ works. There, the static constructors are called by the startup code before main() is called, so it doesn't matter if main() was compiled with the C or the C++ compiler. In fact the runtime library for the C compiler uses static constructors... (!).