I have to unpack a struct in PHP which where written into a fifo. The struct orginal was created by a Qt application and looks like following:
typedef struct {
float32_t fNumberOne;
uint16_t uIntOne; //maybe padding for alignment?
bool_t myOneBitBool;
float32_t fNumberTwo;
} mystruct;
Now, the struct was serialized to write it into a fifo / named-pipe, so that 'the PHP' can read the fifo and unpack() the struct. If you read the fifo, you will get a string. This string you can substr() to get the (in this example) 4byte for the first float fNumberOne. And if you get your substring you can unpack() this with parameters like "f" for float. This works fine for me.
But, as you can see here there are 1 32bit float, 1 16bit int, our 1 bool that only needs 1bit and another 32bit float.
So my question is, if I get my first float and the first 16bit int correctly (byte 1-4 and 5-6) and, how do I get my bool bit out of this struct string (inside position 7?)? And what does the compiler do with the other 15 bits between the bool and the second float(byte rest of 7 and 8)? Are the next following bits are the second float or are they unused? Or does there help any padding to tell the compiler that he have to use another 32bit container?
Or better, how does the struct-string looks on binary level?
For further information, the compiler is not configured at this settings. It is all at standart settings.
many thanks in advance