c-for-go icon indicating copy to clipboard operation
c-for-go copied to clipboard

Can't gernate struct with bit fields

Open mengzhuo opened this issue 4 years ago • 1 comments

struct bpf_insn {
        __u8    code;           /* opcode */
        __u8    dst_reg:4;      /* dest register */
        __u8    src_reg:4;      /* source register */
        __s16   off;            /* signed offset */
        __s32   imm;            /* signed immediate constant */
};

in cgo_helper.go

 var cdst_reg_allocs *cgoAllocMap
 ref51221c46.dst_reg, cdst_reg_allocs = (C.__u8)(x.DstReg), cgoAllocsUnknown
 allocs51221c46.Borrow(cdst_reg_allocs)

But it gets ref51221c46.dst_reg undefined (type *_Ctype_struct_bpf_insn has no field or method dst_reg)

mengzhuo avatar Dec 18 '20 06:12 mengzhuo

Related to Go1.16 ... https://go-review.googlesource.com/c/go/+/252378

mengzhuo avatar Dec 18 '20 07:12 mengzhuo