0

I have a file that contains 7 bytes as little endian, where there is the following:

  • 4 bytes for an int
  • 2 bytes for an unsigned int16
  • 1 byte for a char (signed)

Let's assume I have a struct :

struct A
{
int32_t a;
uint16_t b;
int8_t c;
}

What guarantees do I need on the compiler so that I'm ""alowed"" by the standard to just copy the memory from the file into the struct base adress, without reading member per member ? Is being little endian and having sizeof(A) == 7 enough ?

lezebulon
  • 7,607
  • 11
  • 42
  • 73

0 Answers0