home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1533 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: osse.nrl.navy.mil!jung
  2. From: jung@osse.nrl.navy.mil (Greg Jung)
  3. Newsgroups: comp.sys.amiga.programmer,uiuc.class.cs110c,uiuc.class.cs223
  4. Subject: Re: How do I define my integers?
  5. Date: 17 Jan 1996 20:30:22 GMT
  6. Organization: NRL, Washington, D.C. - Code 7650
  7. Sender: jung@osse.nrl.navy.mil ()
  8. Distribution: world
  9. Message-ID: <4djm8u$rh9@ra.nrl.navy.mil>
  10. References: <4d73ug$25v@vixen.cso.uiuc.edu> <D33Xx*bB0@mkmk.in-chemnitz.de>
  11. Reply-To: jung@osse.nrl.navy.mil ()
  12. NNTP-Posting-Host: ossen.nrl.navy.mil
  13. X-Newsreader: mxrn 6.18-32
  14.  
  15.  
  16. In article <D33Xx*bB0@mkmk.in-chemnitz.de>, floh@mkmk.in-chemnitz.de (Andre Weissflog) writes:
  17. |>In article <4d73ug$25v@vixen.cso.uiuc.edu>, howard daniel joseph writes:
  18. |>
  19. |>>       Okay. I'm writing a program under GCC on my Amiga.
  20.    Since we're talking GCC, we're hoping for a cross-platform type of
  21.   declaration, also in a widely accepted form.  Several answers have been
  22.   given to the elementary form of the question.  However the advancing
  23.   technology makes for a twoer of bable between code applied to the
  24.   standard paradigm, (short = 16bits, long=32 bits, quad=64bits, byte=8bits)
  25.   connected to currently popular computers, and other architectures.
  26.  
  27.      I've just been editing code where the size of the integer does
  28.    matter explicitly, bytes might be swapped depending on machine, 
  29.    and it reads real data in 16-bit chunks.  The lamers claimed to have
  30.    written it in  '92 or '93 it used old-style function declarations
  31.    and everywhere "int" is assumed to be 16 bits.  "short" is never
  32.    used.
  33. |>> 
  34. |>The only rule about int types in C is IMHO that
  35. |>
  36. |>    short <= int <= long
  37. |>
  38.    This is insufficient for my purposes. 
  39.   I need a symbol that
  40.   says "8 bits, like a char", "16 bits, like a signed int",
  41.   "32 bits, like a (un)signed integer". 
  42.  
  43. |>With most Amiga compilers, "short" holds 16 bit accuracy,
  44. |>"int" and "long" hold 32 bits. On the PC, older "16-bit compilers"
  45. |>have often 16 bit ints.
  46.  
  47.    By customary usage, "int" should be the size of the native pointer,
  48.   maybe, "long","short" should be arithmetic types, and "int" is
  49.   just a counter/arbitrary integer.  That's what I adopt but it is
  50.   still left ambiguous when you know that when someone on a Cray says "word"
  51.   it is 64 bits, when he(/she - 1%) says "double" that means 128 bits.
  52. |>
  53. |>The best solution is to consistently use the types defined in 
  54. |><exec/types.h>, called
  55. |>
  56. |>    BYTE    - signed (8-bit) byte
  57. |>    UBYTE   - unsigned (8-bit) byte
  58. |>    WORD    - the same for 16 bit
  59. |>    UWORD
  60. |>    LONG    - the same for 32 bits
  61. |>    ULONG
  62.  
  63.    This would be fine, but it is relevant to general C-code not just
  64.   amiga-specific structures that it is important.  To say that UWORD
  65.   is not compiler dependent is bogus because it is only used on the 
  66.   Amiga.
  67.  
  68. Greg
  69.