home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / arch / 8873 < prev    next >
Encoding:
Text File  |  1992-08-12  |  2.4 KB  |  68 lines

  1. Path: sparky!uunet!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!menudo.uh.edu!sugar!ficc!peter
  2. From: peter@ferranti.com (peter da silva)
  3. Newsgroups: comp.arch
  4. Subject: Re: 32 => 64 Transition
  5. Message-ID: <id.UHAS.9TA@ferranti.com>
  6. Date: 12 Aug 92 14:46:45 GMT
  7. References: <340@moene.indiv.nluug.nl> <1992Aug08.165832.114442@cs.cmu.edu> <1992Aug11.125326.16719@email.tuwien.ac.at>
  8. Reply-To: peter@ferranti.com (Peter da Silva)
  9. Organization: Xenix Support, FICC
  10. Lines: 56
  11.  
  12. In article <1992Aug08.165832.114442@cs.cmu.edu>, lindsay+@cs.cmu.edu (Donald Lindsay) writes:
  13. > [DEC]    32-bit system    64-bit system
  14.  
  15. > char         8         8
  16. > short        16        16
  17. > int        32        32
  18. > long        32        64
  19. > long long    to be added    64
  20. > pointer    32        64
  21.  
  22. I applaud these choices. With them all normal integer sizes remain available,
  23. and no valid code will be broken.
  24.  
  25. In article <1992Aug11.125326.16719@email.tuwien.ac.at> anton@mips.complang.tuwien.ac.at (Anton Martin Ertl) writes:
  26. > I find these choices bad. IMO the relations between types should be
  27. > preserved. Specifically, pointers and ints should have the same size.
  28.  
  29. But pointers and ints *aren't* the same size. Look:
  30.  
  31. + cat test.c 
  32. #include <stdio.h>
  33.  
  34. main()
  35. {
  36.     printf("sizeof (int) = %d\n", sizeof (int));
  37.     printf("sizeof (char *) = %d\n", sizeof (char *));
  38. }
  39. + cc -Ms -o testsmall test.c 
  40. test.c
  41. + cc -Ml -o testlarge test.c 
  42. test.c
  43. + testsmall 
  44. sizeof (int) = 2
  45. sizeof (char *) = 2
  46. + testlarge 
  47. sizeof (int) = 2
  48. sizeof (char *) = 4
  49.  
  50. > Well-written programs hide dependencies on type sizes by defining
  51. > types like Int32. They read machine-independent data from files by
  52. > using XDR or sgetl or ASCII data anyway.
  53.  
  54. Well written programs don't assume that sizeof (int) == sizeof (char *).
  55. This is the classic vaxocentric coding error. It's caused me untold grief
  56. over the past 5 years, and will cause untold grief for other programmers
  57. over the next 5. It's a pity that 64-bit machines will only exacerbate the
  58. infamous "infinite VM" fallacy, though.
  59.  
  60. What size would *you* make an int? 64 bits? What do you do for a 32-bit
  61. data type? Short? Then what do you do for a 16-bit data type? Create another
  62. abomination "short short" or "long char"? "long long" is bad enough.
  63. -- 
  64. Peter da Silva                                               `-_-'
  65. $ EDIT/TECO LOVE                                              'U` 
  66. %TECO-W-OLDJOKE Not war?                        Have you hugged your wolf today?
  67. Ferranti Intl. Ctls. Corp.      Sugar Land, TX  77487-5012       +1 713 274 5180
  68.