Hi,
I need to replicate the idea of C bitfields.
struct iphdr {
__u8 ihl:4,
version:4;
}
but in Nim, the closest I got is:
IP_packet = object
version{.bitsize:4.}:uint8
ihl{.bitsize:4.}:uint8
But it compiles to usual uint8 bytes (two uint8 in that case, when I should have 4 bits for each into one uint8) So, how should I do it?
Thanks,
Thanks you,
For some reason, it now works as expected, even without the packed pragma (which I will use anyway). The code produced is the correct one. The only difference on my systems (osx and linux) is that I changed from "brew install nim" or "apt install nim" to choosenim for both.
Maybe..
Anyway, thanks mashingan,