[Xcb] [PATCH lib] c_client.py: Handle opt. packed attr. in structs

Daniel Martin consume.noise at gmail.com
Sun Dec 23 04:51:48 PST 2012

If the packed attribute is set, we've to add __attribute__((packed)) to
the struct definition.

This is necessary if we would like to prevent gcc from padding structs
to a 4byte boundary.

see Bug #23403:

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
 src/c_client.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/c_client.py b/src/c_client.py
index ec66223..1ec4b9e 100644
--- a/src/c_client.py
+++ b/src/c_client.py
@@ -1806,7 +1806,10 @@ def _c_complex(self):
             if b.type.has_name:
                 _h('    } %s;', b.c_field_name)
-    _h('} %s;', self.c_type)
+    if hasattr(self, 'packed') and self.packed:
+        _h('} __attribute__((packed)) %s;', self.c_type)
+    else:
+        _h('} %s;', self.c_type)
 def c_struct(self, name):

More information about the Xcb mailing list