Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!warwick!nott-cs!gas From: gas@cs.nott.ac.uk (Alan Shepherd) Newsgroups: comp.lang.c++ Subject: bug with making C++ functions have C linkage ? Message-ID: <1991Apr16.122905.23613@cs.nott.ac.uk> Date: 16 Apr 91 12:29:05 GMT Reply-To: gas@cs.nott.ac.uk () Organization: Nottingham University Lines: 33 From my understanding, the correct way to make C++ functions accessible from modules compiled with c is to delcare them extern "C" as in the following example: #include extern "C" void tryCout(); void tryCout() { cout << "Hello World\n"; } Now this can be called from a program compiled with cc. For example, the following program: extern void tryCout(); main() { tryCout(); } This happily compiles without any warnings. However, when running, a segv occurs in the cout operation. This segv disappears if both modules are compiled with CC instead of just the first. Adding another level of indirection to the code by writing another function to call tryCout doesn't work either. Is this a bug ? It certainly looks like it ! Alan Shepherd