home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20036 < prev    next >
Encoding:
Text File  |  1993-01-21  |  1.7 KB  |  41 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!warrane.connect.com.au!g2syd!roberts
  3. From: roberts@g2syd.genasys.com.au (Robert Swan)
  4. Subject: offsetof in case labels
  5. Message-ID: <1993Jan21.232337.6527@g2syd.genasys.com.au>
  6. Organization: Genasys II, Sydney, Australia
  7. Date: Thu, 21 Jan 1993 23:23:37 GMT
  8. Lines: 31
  9.  
  10. I posted a related question a week or two ago.  ~no response, so I'll
  11. try a different tack.
  12.  
  13. We have a problem on various machines using the offsetof macro from
  14. stddef.h in case labels.  These machines all reject the expression as
  15. being non-constant.
  16.  
  17. A representative of one of the machine vendors (IBM), has glibly stated
  18. that the compiler is doing the right thing by rejecting it.  He has
  19. quoted the ANSI standard arguing (in fairly obscure terms) that the
  20. compiler is free to treat various pointer expressions as non constant.
  21.  
  22. I consider this to be irrelevant, since (as I understand it) the
  23. offsetof macro returns, by definition, a constant expression - exactly
  24. what a case label needs.  The fact that it is usually (always)
  25. implemented as a pointer expression is an implementation detail.
  26.  
  27. However, I'm pretty much at sea with the ANSI standard - we don't have a
  28. copy, and the excerpts I have seen of it suggest that it is written in
  29. sufficiently obscure legalese to cloud the superficial interpretation I
  30. might put on it.  Could someone who has invested the considerable
  31. effort to understand the standard please clear this up for me.
  32.  
  33. Should offsetof be usable in case labels?
  34.  
  35. Have fun,
  36.  
  37. Robert.
  38. -- 
  39. I used to be indecisive,   | Robert Swan, roberts@g2syd.genasys.com.au
  40. but now I'm not so sure.   | Genasys II Pty. Ltd., North Sydney.
  41.