Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!deimos.cis.ksu.edu!rutgers!att!pegasus!hansen From: hansen@pegasus.ATT.COM (Tony L. Hansen) Newsgroups: comp.lang.c++ Subject: Re: C --> C++ Summary: cfront 2.0 does not mangle extern "C" names Keywords: extern, linkage specifications Message-ID: <2857@pegasus.ATT.COM> Date: 4 May 89 01:28:53 GMT References: <6590096@hplsla.HP.COM> <11437@ulysses.homer.nj.att.com> <578@hrc63.co.uk> Reply-To: hansen@pegasus.ATT.COM (Tony L. Hansen) Organization: AT&T Bell Laboratories, Lincroft, NJ, USA Lines: 47 <> >Can you <> >do a extern "C" like construct that goes the other <> >way? <> <> You should have added "in a portable way"... <> Since C++ doesn't have a standard naming convention for generating <> unique names for the loader, each compiler does its own name mangling. < < Yes, but I should be able to tell the compiler "dont mangle this function < name". A #pragma or something. It would still be callable from C++ (via < the `extern "C"' mechanism). < < Speaking as someone who has tried to do this, I think it is a major gap in < the langauge. The extern "language" linkage specification works both ways. Not only can one specify that a function has been written in C, one can also specify that a C++ function is to be linked just as a C function would be linked. For example, #include extern "C" void foo() { printf("foo\n"); } void bar() { printf("bar\n"); } main() { foo(); bar(); } the function "bar" will be known externally as the mangled name (such as "bar__Fv" or "bar__Nv"), but the function "foo" will be known externally as the unmangled name "foo". Both cfront 2.0 and Zortech's next C++ compiler work this way. By the way, the next version of Zortech's C++ compiler will also support the extern "Pascal" linkage specification, in addition to the extern "C" and "C++" linkage specifications. Tony Hansen att!pegasus!hansen, attmail!tony hansen@pegasus.att.com