home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / std / c / 2992 < prev    next >
Encoding:
Text File  |  1992-11-08  |  2.5 KB  |  49 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!haven.umd.edu!decuac!pa.dec.com!nntpd2.cxo.dec.com!nntpd.lkg.dec.com!e2big.mko.dec.com!jrdzzz.jrd.dec.com!jit345.bad.jit.dec.com!diamond
  3. From: diamond@jit345.bad.jit.dec.com (Norman Diamond)
  4. Subject: Re: Typedefing built in data types
  5. Message-ID: <Bx80HL.GGC@jrd.dec.com>
  6. Followup-To: alt.religion.computers
  7. Sender: usenet@jrd.dec.com (USENET News System)
  8. Nntp-Posting-Host: jit345
  9. Reply-To: diamond@jit.dec.com (Norman Diamond)
  10. Organization: Digital Equipment Corporation Japan , Tokyo
  11. References: <1992Nov3.093404.9124@odin.diku.dk>
  12. Date: Thu, 5 Nov 1992 02:05:44 GMT
  13. Lines: 34
  14.  
  15. In article <1992Nov3.093404.9124@odin.diku.dk> jkut@diku.dk (Jonatan Kutchinsky) writes:
  16. >we simulate a Motorola 68000 processor. We decided decided to typedef the
  17. >built in types char, short, and long to new names, BYTE, WORD, and LWORD.
  18.  
  19. The standard permits these typedefs.  The standard does not rule on style.
  20.  
  21. >The reason why we want to do this, is that we want to emphasize the
  22. >difference between the data used to control the simulation, etc.,
  23. >and the data that the simulated microprocessor is processing. We are using
  24. >ints, chars and longs to do everything else than containing data from the
  25. >simulated memory and registers, and while it is processed by instructions.
  26.  
  27. I personally think that looks very nice.  Some famous programs have similar
  28. typedefs for certain kinds of portability, and some people have wished that
  29. other famous programs would have similar typedefs for data formats that go
  30. over a network, etc.  But this topic belongs in alt.religion.computers.
  31.  
  32. >The problem is that our teacher has the opinion that this use of typedef is
  33. >a bad thing, and that it makes the program less readable when you do not
  34. >know that LWORD really stands for long, without looking in the header file.
  35.  
  36. It is true that you don't know that LWORD really stands for long, without
  37. looking in the header file.  Also you don't know how many bits long has,
  38. without looking in the C implementation's manuals.  You have to read or else
  39. hope that it happens to be the correct length for the simulated processor.
  40. This topic belongs in, I don't know, maybe comp.software-eng.
  41.  
  42. Your teacher is allowed to believe that this use of typedef is a bad thing
  43. (at least, I think Danish laws allow freedom of belief :-)
  44. Followups are directed to alt.religion.computers.
  45. --
  46. Norman Diamond       diamond@jit081.enet.dec.com
  47. If this were the company's opinion, I wouldn't be allowed to post it.
  48. "It's been a lovely recession."
  49.