Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!bionet!ames!xanth!mcnc!ncsuvx!ecemwl!jnh From: jnh@ecemwl.ncsu.edu (Joseph N. Hall) Newsgroups: comp.lang.c++ Subject: Re: "Type-safe" Linkage? Keywords: C++ 2.0 Message-ID: <4321@ncsuvx.ncsu.edu> Date: 26 Oct 89 21:15:34 GMT References: <2118@leah.Albany.Edu> Sender: news@ncsuvx.ncsu.edu Reply-To: jnh@ecemwl.UUCP (Joseph N. Hall) Organization: North Carolina State University Lines: 27 In article <2118@leah.Albany.Edu> bv3456@leah.albany.edu (Victor @ The Concrete Museum) writes: > >I thought I read somewhere on this group that C++ now has "type-safe" >linkage. Is this so, or was I halucinating? If such a feature exists, >how is it done? The type information is encoded into the "mangled" function names. Two functions with the same name but different argument or return types are given distinct mangled names. This requires no extra smarts on the part of the linker, although it does require that the linker handle relatively long symbols (I don't know what the minimum allowed by C++ 2.0 is, but I'd guess it's around 32 characters). This also allows the linker to catch usage errors resulting from improperly declared functions (or undeclared functions), or functions called with the wrong number/types of arguments, etc. All in all it's a pretty good deal; it's unlikely that linkers that can cope with type information will be ubiquitous any time soon, and this is about as elegant a workaround as is possible within the constraints of C++ and the UNIX-like environment. See the "Selected Readings" book from AT&T for the Stroustrup paper about this feature. v v sssss|| joseph hall || 4116 Brewster Drive v v s s || jnh@ecemwl.ncsu.edu (Internet) || Raleigh, NC 27606 v sss || SP Software/CAD Tool Developer, Mac Hacker and Keyboardist -----------|| Disclaimer: NCSU may not share my views, but is welcome to.