>It's the compiler's prerogative to decide just how
>the fields should be packed so therefore, the construct is never portable.

it's worse than that: you can't use them to access hardware structures, since
(especially if values are misaligned) there's no guarantee that the generated
code will access them as the hardware requires. you can use them to access 
existing
software structures from another system, which is why they were added 
originally,
but even then i'm sceptical, because misaligned accesses only work on x86
(and then only if the kernel doesn't set the alignment trap).
on sparc, arm, and powerpc, you'll get a trap. it was much the same with gcc
last time i checked (but that was some time ago). i remember seeing that
linux on arm handles misaligned traps by interpreting code in the kernel.
(it wasn't for the gcc equivalent of pragma packed, but to support rotten code
from x86.) either way, this seems unlikely to encourage good performance.

it might be better to write a sed or sam script to transform incoming
structure definitions into uchar x[] style.

Reply via email to