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

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!stanford.edu!lucid.com!lucid.com!jss
  3. From: jss@lucid.com (Jerry Schwarz)
  4. Subject: Re: Compatability of enum types and integer types
  5. Message-ID: <1992Dec22.203938.29580@lucid.com>
  6. Sender: usenet@lucid.com
  7. Reply-To: jss@lucid.com (Jerry Schwarz)
  8. Organization: Lucid, Inc.
  9. References:  <1992Dec21.225604.18749@netcom.com>
  10. Date: Tue, 22 Dec 92 20:39:38 GMT
  11. Lines: 47
  12.  
  13. In article <1992Dec21.225604.18749@netcom.com>, rfg@netcom.com (Ronald F. Guilmette) writes:
  14. |> The ANSI C standard says (in 3.5.2.2):
  15. |> 
  16. |>     "Each enumerated type shall be compatible with an integer type;
  17. |>     the choice of type is implementation-defined."
  18. |> 
  19. |> I am having a polite disagreement with one implementor regarding the
  20. |> proper interpretation of this statement.
  21. |> 
  22. |> I interpret it to mean that there *must* exist some integer type `T'
  23. |> such that:
  24. |> 
  25. |>         enum E { red, green, blue };
  26. |> 
  27. |>         enum E object;
  28. |>         T object;
  29. |> 
  30. |>         enum E *ptr;
  31. |>         T *ptr;
  32. |> 
  33. |> ... is a valid translation unit.
  34.  
  35. It requires more for
  36.  
  37.     enum E object ;
  38.     int object ;
  39.  
  40. to be legal than that E and int be compatible. 3.1.2.6 
  41. says that the "type of the identifier becomes the composite type".
  42. It also gives the rules for determining a composite type and
  43. says nothing about combining enums and integer types.  Granted,
  44. this isn't a constraint section, but if there isn't a composite
  45. type then I think the compiler is justified in treating the above
  46. as an error.
  47.  
  48. [Maybe I'm stretching. I feel strongly that the above ought
  49. to be an error and I went looking for a way to make it so. I'm
  50. assuming that the original x3j11 committee didn't intend to force
  51. us to accept code like the above, but I wasn't a member.]
  52.  
  53.     -- Jerry Schwarz
  54.  
  55.  
  56.  
  57.  
  58.  
  59.   -- Jerry Schwarz
  60.