Chuck.Phillips@FtCollins.NCR.COM (Chuck.Phillips) (06/15/90)
>>>>> On 14 Jun 90 19:02:05 GMT, gwyn@smoke.BRL.MIL (Doug Gwyn) said: Doug> You can count on a pointer to the first member of a struct being Doug> convertible to a pointer to the struct and vice-versa, ... By explicit casting, I certainly _hope_ so! :-) Doug> ...and from Doug> various constraints in the standard it is possible to conclude Doug> that "all structure pointers smell the same", meaning that they Doug> have the same size and alignment requirements, so it is also Doug> possible to interconvert pointers to two different structure Doug> types. I want to make sure I'm clear on this. Of course, everything malloc()ed will have the same alignment restrictions because malloc() determines the restrictions. But what about automatic and static structs? For example, a struct composed entirely of char's is often less alignment limited _by the hardware_ than a struct beginning with a double. For example: struct AllChars { char First; char Second[42]; }; int DoSomething () { char OneChar; struct AllChars WhatAboutMe; ... } Are you saying (and is the standard saying) "WhatAboutMe" is _guaranteed_ to have the most restrictive alignment requirements? Are you also saying that on machines where char's have a unique representation (i.e. different number of bits or different interpretation of bits) that "&WhatAboutMe" _must_ be the same kind of pointer as is used for a struct with a double as its first element? I'd expect both the alignment and the pointer representation to be implementation defined, unless it is explicitly mandated in the standard. Thanks in advance, -- Chuck Phillips MS440 NCR Microelectronics Chuck.Phillips%FtCollins.NCR.com Ft. Collins, CO. 80525 uunet!ncrlnk!ncr-mpd!bach!chuckp