thanks all, I will use uint8 and the operators '| & &^'. 2017-10-16 12:33 GMT+08:00 Rob Pike <r...@golang.org>:
> C shouldn't support bitfields either, but that's off-topic. > > -rob > > > On Mon, Oct 16, 2017 at 3:14 PM, Dave Cheney <d...@cheney.net> wrote: > >> Sorry, Go does not support C's bitfields >> >> >> On Monday, 16 October 2017 14:50:48 UTC+11, sheepbao wrote: >>> >>> is golang has any like this represents a bit in struct in c language : >>> >>> >>> struct tcphdr { >>> uint16_t sport; >>> uint16_t dport; >>> uint32_t seq; >>> uint32_t ack_seq; >>> uint8_t rsvd : 4; >>> uint8_t hl : 4; >>> uint8_t fin : 1, >>> syn : 1, >>> rst : 1, >>> psh : 1, >>> ack : 1, >>> urg : 1, >>> ece : 1, >>> cwr : 1; >>> uint16_t win; >>> uint16_t csum; >>> uint16_t urp; >>> uint8_t data[]; >>> } __attribute__((packed)); >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "golang-nuts" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to golang-nuts+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/golang-nuts/z3zyiIZaMWc/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.