Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!zaphod.mps.ohio-state.edu!wuarchive!uunet!stanford.edu!agate!ucbvax!janus.Berkeley.EDU!jbuck From: jbuck@janus.Berkeley.EDU (Joe Buck) Newsgroups: comp.lang.c++ Subject: Portability of compiled libraries (was Re: Name Mangling) Message-ID: <42018@ucbvax.BERKELEY.EDU> Date: 1 May 91 17:51:39 GMT References: <1991May1.112346.13948@fmrco> Sender: nobody@ucbvax.BERKELEY.EDU Organization: U.C. Berkeley Lines: 23 In article <1991May1.112346.13948@fmrco> harold@fmrco (Harold Naparst) writes: > >To what extent can a library compiled with compiler A be used >by a program compiled with compiler B ? > >My question concerns the uniqueness of the name mangling scheme. No, it doesn't. That is, name mangling is the least of your problems. You also need for both compilers to implement virtual functions in the same way; otherwise, virtual function calls using classes defined in the library won't work right. g++ and cfront differ in how they do virtual functions; the g++ scheme never does more than two pointer dereferences and the cfront scheme is often less efficient. In general, there are tricks that can be played by compilers that go directly to assembly language that can't be used by compilers that go to C (trivial example: use a specified register to contain the "this" pointer), and it's unreasonable to expect the writers of such compilers to give up competitive advantages to be compatible with cfront. -- Joe Buck jbuck@janus.berkeley.edu {uunet,ucbvax}!janus.berkeley.edu!jbuck