home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / std / c / 3251 < prev    next >
Encoding:
Text File  |  1992-12-22  |  1.7 KB  |  50 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!spool.mu.edu!umn.edu!csus.edu!netcom.com!rfg
  3. From: rfg@netcom.com (Ronald F. Guilmette)
  4. Subject: Compatability of enum types and integer types
  5. Message-ID: <1992Dec21.225604.18749@netcom.com>
  6. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  7. Date: Mon, 21 Dec 1992 22:56:04 GMT
  8. Lines: 40
  9.  
  10. The ANSI C standard says (in 3.5.2.2):
  11.  
  12.     "Each enumerated type shall be compatible with an integer type;
  13.     the choice of type is implementation-defined."
  14.  
  15. I am having a polite disagreement with one implementor regarding the
  16. proper interpretation of this statement.
  17.  
  18. I interpret it to mean that there *must* exist some integer type `T'
  19. such that:
  20.  
  21.         enum E { red, green, blue };
  22.  
  23.         enum E object;
  24.         T object;
  25.  
  26.         enum E *ptr;
  27.         T *ptr;
  28.  
  29. ... is a valid translation unit.
  30.  
  31. The person on the other side of this discussion seems to be claiming that
  32. indeed the standard requires the existence of such an integer type, but
  33. that the implementation may "put the fix in" so that no matter what type
  34. you try to use for `T', the implementation will say "Sorry.  You guessed
  35. wrong.  I'm using a different integer type as the `compatible' type for
  36. that particular enum type."
  37.  
  38. Does this sound like dirty pool or what?
  39.  
  40. -- 
  41.  
  42. // Ron ("Loose Cannon") Guilmette    uucp: ...uunet!lupine!segfault!rfg
  43. //
  44. //      "On the one hand I knew that programs could have a compelling
  45. //       and deep logical beauty, on the other hand I was forced to
  46. //       admit that most programs are presented in a way fit for
  47. //       mechanical execution, but even if of any beauty at all,
  48. //       totally unfit for human appreciation."
  49. //                                              -- Edsger W. Dijkstra
  50.