In code where data structure padding is used, such as union, struct, or bit field, the host test result may differ from the target test result.
When compiler meets structs or bit fields, it inserts additional bytes after the space allocated for member variables so that the CPU can access data efficiently. This technique is called data structure padding.
Depending on the system, the compiler inserts addtional bytes so that the address of a member variable is a multiple of 4 bytes, 8 bytes, and so on.

struct MyData
{
    char Data1;
    long Data2;
    int Data3;
};

When Data1 is allocated to nth byte, you might think Data2 is located at n+2th byte, but it is actually located at n+4 or n+8th byte, because the compiler inserts additional bytes to make address of Data2 multiple of 4 or 8 bytes.
The number of bytes to be inserted depends on the compiler and system. The address of long-type variable should be multiple of of 4 bytes on an x86 system and a multiple of 8 bytes on an x64 system.
Because of this, source code with unions, structs, bit fields, etc. where data structure padding is used, the host test results may differ from the target test result.
You should test on the target system or modify the code to fit on the host system.

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.