I'm writing an Symbian application where I have to encode/decode a binary
data protocol consisting of TLV (tag, lenght, value) blocks. On
Windows/Linux I am used to work with structs and the #pragma pack() macro.
So if the protocol says

Value Size(Bits)
val1 8
val2 4
val3 4

i would define a struct

#pragma pack(1) // for 1 byte aligning instead of 4 byte (32bit)
struct TLV {
TUint8 val1; // offset of next value would be 8 bits (and not
32bits as without #pragma)
TUint val2:4; // define length of data as 4 bits
TUint val3:4; // same
#pragma pack(4) // we don't want to slow down the rest of our code, so
we re-enable 32bit alignment

Then I could copy a 16bit value "TUint16 myData" into the struct with

Mem::Copy(&iTlv, myData, 2); // to copy 2 bytes.

The size of iTlv should be 2 bytes and on WINS emulator sizeof(iTlv) returns
"2" but on the device (ARMI - S60) it returns "4" (as to expect with 32bit

How can I get this working on ARMI devices (like 3650)? Is the #pragma
pack() directive supported by a newer version of gcc? I'm using the Series
60 V0.9 SDK packed with Codewarrior.