one pragma pack vs. many, many __attribute__((packed))

From: Steve French
Date: Thu Oct 27 2005 - 14:47:17 EST


Seems like a big annoyance, but gcc on some platforms (arm) will
generate different code for
pragma pack(1)
vis the corresponding more verbose alternative ie specifying
__attribute__((packed))
on each structure one by one. Presumably there are good reasons for why
packing them across the whole file does not mean you can necessarily
read them when they aren't aligned (my imagination is not that good)

Although it makes the code more verbose to individually call out packing
on each structure, I don't see any reasonable alternative that would
work (at least on arm) as I have to deal with structures coming in off
the network that are packed - and in some cases not aligned on 2 or 4
byte boundaries either. special case parsing them off the wire (as
opposed to accessing them with their structure field names) would be
worse, and copying them into a temp buffer would be worse ... are there
no reasonable magic compile options or pragmas that will have the effect
of attribute__((packed)) without being so verbose?




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/