samedi 18 avril 2015

__attribute__ packed of an integer

in the gcc documentation they give information on how integers can be aligned. Can the same thing be done for packing integers?


For example, is this valid on a system that doesn't do automatically handle improperly aligned data?



typedef uint16_t __attribute__ ((packed)) packed_uint16_t;


On my system it gives:



align.c:7:1: warning: ‘packed’ attribute ignored [-Wattributes]


typedef uint16_t attribute ((packed)) packed_uint16_t;



But my system properly handles unaligned bytes, so I guess it would ignore it then!


This is a follow up to this question


Aucun commentaire:

Enregistrer un commentaire