While it is true that compilers pad for alignment it is pretty easy to avoid that, at least in my experience.<p>So an easier approach, but more fragile, is just to define the struct, count up how big you think it
should be and then do an<p>assert(sizeof(struct foo) == FOO_SIZE);<p>If that assert doesn&#x27;t pop then you can just do<p>write(fd, &amp;foo, FOO_SIZE);<p>I know that is a lot less elegant but it works and isn&#x27;t doing the translation back and forth.<p>If you don&#x27;t like that you might consider using Sun&#x27;s RPC marshalling code that is (used to be?)
part of Linux.