Garrett D'Amore writes: > However, for certain use cases -- like network protocols and on-disk > formats, I think packing is completely reasonable. In those cases, be > certain you use intXX_t, e.g. int32_t, uint16_t, etc. rather than > relying on the size of native data types. > > Of course, I don't work for Sun, and I don't speak for Solaris. But its > just my opinion.
Do work for Sun, but I'm not so sure I speak for all of Solaris. ;-} I wouldn't use packing at all. SPARC and some other platforms don't support unaligned accesses, and the temptation is just too great to use such a structure inappropriately -- leading to a core dump in user space, or system panic in kernel space. Plus, they're annoying to use, because every compiler deals with them slightly differently. I can't say I've ever run into a case where explicitly packed structures were really all that interesting. There seem to be others who use them frequently, but I don't. (I _do_ rely on the fact that objects within a structure are padded to an alignment no greater than the natural size of the object. In other words, if a 'char' member were padded out to a 2-byte alignment, I'd be quite disappointed. So would the system. ;-}) -- James Carlson, KISS Network <[EMAIL PROTECTED]> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 _______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
