Void_Star <praveen_athimon@xxxxxxxxxxxxxx> writes: > I have a porting issue related with the migration to GCC from DIAB compiler. > The RTOS used is AMX and the platform is PowerPC. The code earlier compiled > with Diab has the following pragma usage > > DIAB: > ----- > #pragma pack [ ([[max_member_alignment], [min_structure_alignment] [, > byte-swap]]) ] > where byte-swap means: > If 0 or absent, bytes are taken as is. If 1, bytes are swapped when > the data is transferred between byte-swapped members and registers or > non-byte-swapped memory. This enables access to little-endian data on a > big-endian machine and vice-versa. > (w.ref.to http://www.vxdev.com/docs/vx55man/diab5.0ppc/c-additi.htm#3000472 > : page 132) > ----- > GCC ignores the usage #pragma pack(1, 1, 0) and #pragma pack(1, 1, 1) at > several places related with structures of different packet types avoiding > structure packing. I can manage with #pragma pack(1) while using GCC, but I > am concerned how the third parameter 'byte-swap' specifying the 'endianness' > can affect the code behaviour. Is there any way we can mention this > endianness also? Can anyone please share your thoughts on this? I don't see any support in gcc for specifying that some data is little-endian on a big-endian target, or vice-versa. I think you are going to need to insert explicit byte swaps where the DIAB compiler sets the byte-swap field to 1. gcc provides functions like __builtin_bswap32 which you can use for this. If you use those with a memory load or store, gcc will generate a byte swapping load/store instruction on PPC. Ian