home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / mac / programm / 20658 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  2.2 KB

  1. Path: sparky!uunet!spool.mu.edu!wupost!waikato.ac.nz!ldo
  2. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: short/long ints (was Re: Sozobon C...)
  5. Message-ID: <1993Jan5.174802.13028@waikato.ac.nz>
  6. Date: 5 Jan 93 17:48:02 +1300
  7. References: <29848@castle.ed.ac.uk> <3917@isgtec.isgtec.com> <C0AKGC.IsJ@news.cso.uiuc.edu> <1993Jan4.202040.26524@reed.edu>
  8. Organization: University of Waikato, Hamilton, New Zealand
  9. Lines: 30
  10.  
  11. In article <1993Jan4.202040.26524@reed.edu>, bowman@reed.edu (BoBolicious) writes:
  12. >
  13. > I *guess* you could talk about a "Mac int standard", but what's really going
  14. > on is that Pascal uses 16-bit ints.  Most C compilers these days use 32-bit
  15. > ints.  Personally, I think ints are stupid to use, because of this uncertainty
  16. > as to what is meant; far better to specifically use shorts & longs.
  17.  
  18. Back when I used to program voluntarily in Fortran, I developed this convention
  19. that I would explicitly use INTEGER*2 or INTEGER*4 wherever it mattered, and
  20. just use INTEGER wherever it didn't. This way my code could compile with
  21. either the /I4 (INTEGER = INTEGER*4) or /NOI4 (INTEGER = INTEGER*2) switch,
  22. and so long as I used the same switch setting with all my modules, the final
  23. program would run OK.
  24.  
  25. Now that I use Modula-2, I have adopted the same convention. The compiler
  26. I use interprets INTEGER and CARDINAL types as 16 bits, and LONGINT and
  27. LONGCARD types as 32 bits. What I did was define ShortInt and ShortCard
  28. types in my Types.def interface file, and I use these (and LONGINT/LONGCARD)
  29. where it matters, leaving direct use of INTEGER and CARDINAL for those places
  30. where it doesn't. This way I only need to make a change in one place. I don't
  31. even have to worry about compiling different parts of the same program with
  32. different versions of the interface file, as Modula-2 doesn't allow you to
  33. make that kind of mistake.
  34.  
  35. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  36. Computer Services Dept                     fax: +64-7-838-4066
  37. University of Waikato            electric mail: ldo@waikato.ac.nz
  38. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00
  39. If there is no such thing as a free lunch, then where did the universe
  40. come from?
  41.