home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / solaris / 103 < prev    next >
Encoding:
Text File  |  1992-07-22  |  5.2 KB  |  129 lines

  1. Xref: sparky comp.unix.solaris:103 comp.sys.sun.apps:1447 comp.sys.sun.misc:3272 comp.sys.sun.admin:4863
  2. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!agate!stanford.edu!rutgers!micro-heart-of-gold.mit.edu!xn.ll.mit.edu!ll.mit.edu!cynthia
  3. From: cynthia@ll.mit.edu (Cynthia Eldridge)
  4. Newsgroups: comp.unix.solaris,comp.sys.sun.apps,ll.bboard,comp.sys.sun.misc,comp.sys.sun.admin
  5. Subject: SUMMARY: Converting K&R to ANSI C
  6. Message-ID: <1992Jul22.140413.15855@ll.mit.edu>
  7. Date: 22 Jul 92 14:04:13 GMT
  8. Sender: news@ll.mit.edu
  9. Organization: MIT Lincoln Laboratory, Lexington MA
  10. Lines: 116
  11. Originator: cynthia@ll.mit.edu (Cynthia Eldridge)
  12.  
  13.  
  14. I received many helpful replies in response to my plea for
  15. recommendations/comments/advice on the best way to convert
  16. a very large volume of Kernighan and Ritchie C (K&R) to ANSI-C
  17. (ACC).  I asked several questions hoping to get an idea on the 
  18. best way to convert our software.  In particular, we are trying to
  19. decide whether we should convert our software all at once to ACC,
  20. perhaps locking it for weeks, or whether we should convert our
  21. software gradually.
  22.  
  23. Basically, the 30 or so responses can be summed up as follows, with
  24. the total number of folks who mentioned the response in ():
  25.  
  26. 1. Don't worry; the Sun compiler has special flags that will support
  27.    a gradual transition.  (11)  These flags are:
  28.     -Xt    supports K&R and ACC; uses K&R semantics
  29.     -Xa    supports K&R and ACC; uses ACC semantics
  30.     -Xc    strictly ACC
  31.  
  32. 2. Don't worry; gcc supports K&R and/or ACC. (16)
  33.  
  34. 3. Require new projects and rewrites to be ACC; use the Sun compiler's
  35.    -Xt flag for old projects.  Clean up old projects gradually. (4)
  36.  
  37. 4. Use lint. (4)
  38.  
  39. 5. Protoize very useful; start with it. (4)
  40.  
  41. 6. Cproto useful, but doesn't handle typedefs. (4) One person said it was
  42.    "a bit of a pain" to use.
  43.  
  44. 7. Convert all at once, using utility (like protoize or cproto). (5)
  45.  
  46. 8. One person sent document on managerial aspect, which pointed out that
  47.    conversion can be tricky and that having good programmers is important.
  48.  
  49. 9. Convert gradually using macros. (7)  For example, the Sun compiler has a
  50.    predefined macro, __STDC__, which has value 0 for -Xt and -Xa, and
  51.    has value 1 for -Xc.
  52.  
  53. 10. There are other compilers, such as MIPSco, that support K&R and ACC. (1)
  54.  
  55. 11. The PipeLine Tool, "svmt", provided by Sun on the Solaris 2.0 Migration 
  56.     CD, is useful. (1)
  57.  
  58. 12. Be careful: in ACC, some K&R preprocessor identifiers may no longer be 
  59.     valid (e.g., "." should not be in a preprocessor). (1)
  60.     Also, note that ACC and K&R treat unsigned types differently, have
  61.     different variable argument list handling, treat "trigrams" (a 3 to 1
  62.     character conversion) differently, etc. (1)  
  63.     Beware of K&R code that addresses (char *) 0 or that frees an 
  64.     unallocated pointer; it won't work in ACC. (1)
  65.  
  66. 13. One person wrote a package called "cextract" to generate header files
  67.     containing full prototypes of functions.  The headers include a macro
  68.     to allow them to be compiled in ACC or in K&R.
  69.  
  70. 14. Don't use automatic converters because they may introduce typos. (1)
  71.  
  72. 15. Don't change anything else when converting the code to ACC to 
  73.     eliminate potentially introduced bugs. (1)
  74.  
  75. 16. Gnu ghostscript comes with a program ansi2knr.c. (1)
  76.  
  77. 17. Centerline (Saber) from CodeCenter is a possibility. (1)
  78.  
  79. 18. QA*C is good for writing maintainable code of high quality, but not
  80.     recommended for merely converting from K&R to ACC. (1)
  81.  
  82. 19. I presented a scheme to typedef library functions to ensure that 
  83.     if the library was compiled in K&R and if the application calling
  84.     the library function was compiled in ACC (or vice-versa), then the
  85.     function would not be promoted to something unexpected.  (For example,
  86.     all functions returning float would be typedef'd to return double
  87.     because K&R promotes floats to doubles but ACC does not.)  Two people
  88.     said this scheme sounded OK.  One person said that it sounded too
  89.     complicated and thus prone to error.
  90.  
  91. Much thanks to:
  92.     Mike.Kade@West.Sun.COM (Michael Kade)
  93.     guy@auspex.com (Guy Harris)
  94.     Keith.Bierman@Eng.Sun.COM (Keith Bierman fpgroup)
  95.     aarond@stortek.com (Aaron Dailey)
  96.     dgg@ksr.com (David G. Grubbs)
  97.     david d `zoo' zuhn <zoo@cygnus.com>
  98.     nmm@cl.cam.ac.uk
  99.     Ronny.Bergstrom@eua.ericsson.se (Ronny Bergstrom)
  100.     P.G.Griffiths <P.G.Griffiths@uk.ac.daresbury>
  101.     Marc Evans - Contract Software Hacker <evans@zk3.dec.com>
  102.     rkc@ll.mit.edu
  103.     nickel@desaster.cs.tu-berlin.de (Juergen Nickelsen)
  104.     davy@ecn.purdue.edu (Dave Curry)
  105.     gstead@ux5.lbl.gov (Graham Stead)
  106.     arensb@kong.gsfc.nasa.gov (Andrew Arensburger - RMS)
  107.     adb@albert.bu.edu (Adam Bryant)
  108.     pacdata!jimh@UCSD.EDU (Jim Harkins)
  109.     "Hilarie Orman" <ho@cs.arizona.edu>
  110.     "Dan Franklin" <dan@diamond.bbn.com>
  111.     alans@ll.mit.edu ( Alan Stein )
  112.     Peter Shipley <shipley@tfs.COM>
  113.     Perry_Hutchison.Portland@xerox.com
  114.     fred@dip1.ee.uct.ac.za (Fred Hoare)
  115.     randy@ncbi.nlm.nih.gov (Rand S. Huntzinger)
  116.     Steve_Kilbane@gec-epl.co.uk
  117.     "Dan Franklin" <dan@diamond.bbn.com>
  118.     Mike Raffety <miker@sbcoc.com>
  119.     georg@sgl.ists.ca (Georg Feil)
  120.     svb@svb.guug.de
  121.     jarocki@dvorak.amd.com (John Jarocki)
  122.     woods@robohack.ll.mit.edu (Greg A. Woods)
  123.  
  124. Cynthia Eldridge
  125. --
  126. Cynthia Eldridge
  127. M.I.T. Lincoln Laboratory
  128. cynthia@ll.mit.edu
  129.