home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / c / 3429 < prev    next >
Encoding:
Text File  |  1993-01-27  |  5.9 KB  |  149 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!usc!howland.reston.ans.net!spool.mu.edu!agate!netsys!pagesat!spssig.spss.com!news.oc.com!utacfd.uta.edu!rwsys!sneaky!gordon
  3. From: gordon@sneaky.lonestar.org (Gordon Burditt)
  4. Subject: Re: Libraries specified in source?
  5. Message-ID: <C1IAB8.D4M@sneaky.lonestar.org>
  6. Organization: Gordon Burditt
  7. References: <1993Jan21.182949.29796@cronkite.ocis.temple.edu> <1993Jan22.013725.5587@nntpd.lkg.dec.com> <1993Jan22.234158.22292@den.mmc.com>
  8. Date: Wed, 27 Jan 1993 09:28:07 GMT
  9. Lines: 138
  10.  
  11. >>Surely the standard can't
  12. >>specify how to use extensions.
  13. >
  14. >Surely the standard can evolve to include a few good ideas, like Ray's
  15. >#library directive.
  16.  
  17. Is it a good idea?  I have my doubts.  However, I think it will need
  18. a lot of polishing before it is implemented.
  19.  
  20. Problem 1:  What's a legal file name?  I don't think there is any
  21. absolute path name that is legal under MS-DOS, VMS, and UNIX.  The
  22. least common denominator is a file name relative to some directory.
  23.  
  24. Include files solved this problem by (1) building in certain names
  25. that HAD to work right, and (2) using file names relative to one
  26. of several system-specific directories.  So let's use relative
  27. file names for the library.
  28.  
  29. Problem #2:  Where are the commonly-used libraries?  386BSD doesn't
  30. HAVE a /lib directory.  On XENIX and V7 UNIX and a lot of other UNIX
  31. systems, libc is in /lib.  Further, XENIX/*86 has various libraries
  32. like /lib/Slibc.a, /lib/Mlibc.a, etc.  Ok, let's use the include
  33. file solution:  you specify part of the library name, and the
  34. compiler searches for it in one of several places.  Ok, instead
  35. of -lm, we now have:
  36.  
  37. # library <m>
  38.  
  39. Maybe we could make that name a bit more descriptive.
  40. In the case of 286 model-ridden implementations, the currently
  41. in use model can select the appropriate library from the available
  42. /lib/[SMCLHGEU]libc.a depending on whether small, medium, compact,
  43. large, huge, gigantic, enormous, or universal model is in use.
  44. (Did I miss any?)  I believe mixed-model constructions may become
  45. a nightmare, although they probably were already.
  46.  
  47. Problem #3:  It invalidates all the code that doesn't specify libraries.
  48. Easy fix:  all the libraries containing the ANSI C functions have to
  49. be included anyway, without asking for them.  That gets rid of the
  50. need for:
  51. # library <m>
  52. # library <c>
  53. in most every source file, because they're implied.
  54.  
  55. Problem #4:  What are the appropriate statements to call on a
  56. particular library?  Well, we can standardize on the names, following
  57. existing conventions.  Now we've got something like:
  58.  
  59. # ifdef BSD
  60. # library <curses>
  61. # library <termcap>
  62. # endif
  63. # ifdef SYSV
  64. # library <curses>
  65. # endif
  66. # ifdef XENIX_SYSV
  67. # library <curses>
  68. # library <termlib>
  69. # endif
  70. # ifdef XENIX_SYSIII
  71. oh, heck, what goes here?
  72. # endif
  73.  
  74. A few appropriate names to standardize might be <curses>, <ndbm>,
  75. <X11>, <yacc>, <lex>, <rpc>, etc.  Note that I'm not ruling out
  76. local libraries invoked with something like:
  77.  
  78. # library "isam"
  79.  
  80. Ok, now some problems I don't have good answers for:
  81.  
  82. Problem #5:  Do I really want to have to edit the source code to
  83. use a different version of a library?  Some systems have different
  84. variants of libraries, such as profiled and non-profiled libraries.
  85. You don't necessarily want all the libraries profiled or all non-profiled.
  86. I really don't want to have to edit the source to use or not use
  87. shared libraries.  
  88.  
  89. This gets particularly frustrating if someone has taken it on
  90. themselves to put # library directives in the system include files
  91. to be helpful.  It could be very helpful, until you want to use
  92. an experimental version of something.
  93.  
  94. Note that it's not unusual to have a library version conflict with
  95. a user supplied version of the same routine, and that warnings for
  96. such a situation are annoying.  The yacc library, for example, contains 
  97. a default main() routine if the user doesn't supply one, but it's
  98. not used if one is supplied.
  99.  
  100. It's also not uncommon to have conflicts between one library and another,
  101. also not deserving of a warning.  System V systems often have two
  102. versions of malloc, one in libc and another in a separate library.
  103.  
  104. Problem #6:  Does library order matter?  With many existing linkers, it
  105. does, especially if libraries call routines in other libraries.
  106. I know, "fix all the linkers".  Sometimes it's not that easy.
  107. And sometimes tricks are used with library order intentionally
  108. to do system-dependent things, like assuring order in the
  109. final executable, or using external references to select one 
  110. of two identically-named routines, often printf() (integer-only
  111. and integer+floating versions).  Maybe these tricks deserve
  112. to die.
  113.  
  114.  
  115. Problem #7:  Does # library select which routine you get when
  116. there are two routines named the same in different libraries?
  117. Example:  a.c and b.c are linked to make a complete program.
  118.  
  119. File a.c:
  120.  
  121. # library <GNUmalloc>
  122. ... uses malloc() ...
  123.  
  124. File b.c:
  125.  
  126. # library <SYSVmalloc>
  127. ... uses malloc()
  128.  
  129. Ok, what happens?  (a) routines in both a.c and b.c use GNUmalloc's
  130. version of malloc(), (b) routines in both a.c and b.c use SYSVmalloc's
  131. version of malloc(), (c) routines in a.c use GNUmalloc's version of malloc(),
  132. and routines in b.c use SYSVmalloc's version of malloc(), (d) you get
  133. a duplicate symbol error, or (e) you get (a) or (b) but can't predict
  134. in advance which.  
  135.  
  136. Suppose you get choice (c), and have two malloc()s in use, and both
  137. malloc()s call __free(), which are defined in their respective libraries.
  138. Neither __free() is declared static.  Which malloc() calls which free()?
  139.  
  140. Problem #8: What happens when linking together many source files, several
  141. of which specify libraries?  Do you use all specified libraries, after
  142. weeding out the duplicates?  What order is used, if it matters?
  143. Given a System V with two versions of malloc() in two different
  144. libraries, both specified, which one gets used?  (This situation
  145. is common practice, I believe).
  146.  
  147.                     Gordon L. Burditt
  148.                     sneaky.lonestar.org!gordon
  149.