How to wrap a C structure which is defined with __attribute__((packed,aligned(1)))?
问题 How do I wrap a C structure which is defined with __attribute__((packed,aligned(1))) in SWIG? 回答1: You need to do almost nothing to make this work, simply #define the attribute away: %module test #define __attribute__(x) struct foo {} __attribute__((packed,aligned(1))); Will parse and work as intended. The reason this works is that SWIG doesn't generate any code that cares about the layout or size of an object. Nor does it generate code that makes any assumptions about it either. Instead all