home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12577 < prev    next >
Encoding:
Internet Message Format  |  1992-08-19  |  2.4 KB

  1. Path: sparky!uunet!ogicse!hp-cv!sdd.hp.com!usc!rpi!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Libraries which depend on compiler (mangling).
  5. Message-ID: <16u0glINN84a@early-bird.think.com>
  6. Date: 19 Aug 92 17:31:01 GMT
  7. Article-I.D.: early-bi.16u0glINN84a
  8. References: <Bt8922.ED4@fulcrum.bt.co.uk>
  9. Organization: Thinking Machines Corporation, Cambridge MA, USA
  10. Lines: 37
  11. NNTP-Posting-Host: telecaster.think.com
  12.  
  13. In article <Bt8922.ED4@fulcrum.bt.co.uk> rct@fulcrum.bt.co.uk (Richard Taylor) writes:
  14. >I suspect this is probably an old chesnut, but I'm new to C++, and have just
  15. >come across the fact that different compilers mangle names in different
  16. >ways (g++ and cfront, in particular).
  17. >This means that when I purchase a library of objects (which happen to have
  18. >been compiled with cfront) I cannot compile my own code (with g++) and link
  19. >it together with the object library, without also purchasing cfront.  In a
  20. >world of releatively portable code, this is an incredible oversight.
  21.  
  22. Is this in the FAQ yet?
  23.  
  24. You're confusing portability with interoperability.  Name mangling is only
  25. a small part of the interoperability problem between code generated by
  26. different compilers.  Other differences include: layout of virtual tables,
  27. layout of class members (in particular, the order of members when multiple
  28. inheritance is used), how "this" is passed in the calling sequence of
  29. member functions, and how global initializers are executed.
  30.  
  31. Until all such things are standardized, there's no point in standardizing
  32. the name mangling.  In fact, compilers are *encouraged* to use unique
  33. mangling schemes, so that the user finds out that he's trying to mix code
  34. from different compilers, which is not likely to work because of the other
  35. problems.
  36.  
  37. BTW, C has similar problems, although not to as large an extent.  By
  38. default GCC uses a different mechanism for returning structure values from
  39. functions than most PCC-based C compilers.  You have to remember to give
  40. GCC the -fpcc-struct-return option to force it to use the older convention
  41. (it's not used by default because it may be less efficient and
  42. non-reentrant).  And if you have a program that must be linked with two
  43. libraries, one of which was compiled with the PCC convention and the other
  44. with GCC's default, you could be screwed.
  45. -- 
  46. Barry Margolin
  47. System Manager, Thinking Machines Corp.
  48.  
  49. barmar@think.com          {uunet,harvard}!think!barmar
  50.