karl@haddock.ISC.COM (Karl Heuer) (01/27/88)
In article <7178@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >In article <2376@haddock.ISC.COM> karl@haddock.ima.isc.com (Karl Heuer) writes: >>Thus, struct{char} and struct{int} may have different alignment constraints. > >I used to think that, too, but a few weeks ago after discussion with >Dennis Ritchie I realized that all struct pointers have to "smell" the >same, which implies that they might as well have the same alignment. The way I see it, you have two choices on a word-addressible machine: either word-align all structures (and use word pointers for struct pointers), or use the minimal required (VAX-like) alignment (and use byte pointers for all structs, even those that are known to be word-aligned.) C vendors on such machines will have to weigh the time-space tradeoff, but there's no reason to penalize the folks who use byte-addressible machines. On a VAX, where all pointers "smell" the same anyway, there should be no problem with struct{char} having char alignment. (Of course, the user can't portably depend on it.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint