[Xcb] compiler padding and sync extension

Aaron Young m.aaron.young at gmail.com
Tue Aug 18 20:19:30 PDT 2009

>> I'm no expert, but I was a little surprised to discover that XCB
>> structures weren't already defined with __attribute__ ((packed)),
>> #pragma pack(1), etc.  Any reason this approach hasn't been adopted?
> Those are not even remotely portable.

True, but my thinking was that it is the only way to garauntee that
casting a char pointer to a struct pointer always works.  Maybe since
much of the X protocol is designed with structure members adhering to
4-byte alignment, this isn't much of an issue....?

> If someone were to propose a patch to fix this, it would probably speed
> up the process quite a bit (hint, hint).

This is a very interesting problem, but I fear a solution that is both
portable and robust might require some rather invasive changes.
Applications I've worked on in the past that converted C structs
to/from binary protocol primitives either used #pragma pack or
explicit (de)serialization routines that (un)packed each structure
member individually.


More information about the Xcb mailing list