home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / c / 2399 < prev    next >
Encoding:
Internet Message Format  |  1992-07-31  |  1.6 KB

  1. Path: sparky!uunet!iWarp.intel.com|eff!world!ksr!jfw
  2. From: jfw@ksr.com (John F. Woods)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Character arrays in structures and address alignment -- any standard?
  5. Message-ID: <14330@ksr.com>
  6. Date: 31 Jul 92 12:42:36 EDT
  7. References: <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com>
  8. Sender: news@ksr.com
  9. Lines: 23
  10.  
  11. bill@twwells.com (T. William Wells) writes:
  12. >In article <14216@ksr.com> jfw@ksr.com (John F. Woods) writes:
  13. >: msb@sq.sq.com (Mark Brader) writes:
  14. >: >> The Standard allows arbitrary padding between fields and after the
  15. >: >> last field.
  16. >: >It does not say anything about padding being permitted
  17. >: >for any other reasons, and my interpretation is that it isn't.
  18. >: Please show a strictly conforming program which can tell the difference
  19. >: between "necessary" padding and "unnecessary" padding.
  20.  
  21. >For example:
  22. >    printf("%d\n", (offsetof(foo, y) - offset(foo, x)) - sizeof(int));
  23. >should print 0 on any standards conforming compiler, if it is true that the
  24. >standard permits only padding for the purpose of creating proper alignment.
  25.  
  26. Conversely, in the absense of any means of deriving from the Standard this
  27. unstated requirement, the program is not strictly conforming.
  28.  
  29. The Rationale isn't the Standard, but I'll quote it anyway: 3.5.2.1 "Since
  30. some existing implementations, in the interest of enhanced access time, leave
  31. internal holes larger than absolutely necessary, it is not clear that a
  32. portable deterministic method can be given for traversing a structure field
  33. by field."
  34.