I have an application that depends on structure sizes. When I compile with the arm g++ and ucLibc my packets are in size chunks of 4 bytes.
I already tried both of these flags -fpack-struct and -fshort-enums. they work when I compile with g++ for an intel ubuntu linux target application, but when I port to the Arm based ConnectME the structures default to 4 byte sizes. any ideas?
I messed around and found that my problem was that my struct was within a union. So using attribute ((packed)) worked when i moved the struct out of the union.
Just to let you know the union had all 1 byte elements, and to be clear my Ubuntu g++ (gcc ver 4.01) compiled it fine when it was in the union. The arm-g++ was gcc ver 2.95.3
also here is an email from Leonid from Digi:
I did some research and discovered that: older versions of G++ had a bug ignoring -fpack-struct: http://gcc.gnu.org/ml/gcc-bugs/1999-02n/msg00633.html
This might be one of the things you are seeing, also attribute ((packed)) is known not to work prior to gcc 4.0.0…
Also have you tried something like this: #pragma pack(2)
int x2 attribute ((aligned(2)));