Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!cs.utexas.edu!uunet!brunix!gjb From: gjb@cs.brown.edu (Gregory Brail) Newsgroups: comp.lang.c++ Subject: SunOS shared libraries and virtual tables Message-ID: <68989@brunix.UUCP> Date: 18 Mar 91 21:48:42 GMT Sender: news@brunix.UUCP Reply-To: gjb@cs.brown.edu (Gregory Brail) Organization: Brown University Department of Computer Science Lines: 33 In SunOS, one can make libraries "shared," which means their code in memory is shared between all processes that use them, and all those executables use the same file to get at the code. However, external initialized data (like global constants, for instance) cannot be shared. One can, however, manually put all external initialized data in a separate part of the library so it won't be shared and the rest of the library will be. With C, this is easy. With C++, however, all virtual tables and pointers to virtual tables fall under the "external initialized data" category, or at least that's how I understand it. Has anyone come up with a good way to solve this problem? One can just ignore the problem with virtual tables -- the shared libraries still work (although less efficiently). One could also use the +e0 and +e1 arguments to cfront by creating one (or a few) files that contain just class definitions and putting those definitions in the non-shared part of the library. This, however, is a pain, and getting a few hundred class definitions into one file isn't easy, to say the least. The shared version of libC that comes with Sun C++ appears to have the virtual tables in the sharable portion of the library. Is this the correct solution, or should one put the virtual tables in the non-shared portion? And if that's the case, what's the easiest way to do that? Thanks in advance for the help. -greg +----------------------------------------------------+ Greg Brail Internet: gjb@cs.brown.edu BITNET: gjb@browncs.bitnet UUCP: ..uunet!brunix!gjb Home: (401)273-1172