Hi Guys,
I'm programing my own TCP/Ip Stack. Therefore I need structs with bitfields.
For eg:
typedef struct __attribute__ ((packed)) { uint16_t srcPort; uint16_t dstPort; uint32_t seq; uint32_t ack; unsigned headerlen : 4; unsigned res : 6; unsigned flags : 6; uint16_t hlenFlags; uint16_t windowSize; uint16_t checksum; uint16_t urgentPtr; } TCP_Header
After the bitfield variables the values aren't right anymore. Can you tell me why is this so?
Thanks for your help best regards Robert
But Robert, a TCP/IP stack is something you certainly want to be able to port. I mean, after all the effort...
Yeah you're right. Seems to be better to access through a 16-bit word.
But in general, how can I solve this problem? Are there specific compiler options?