You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cgo no longer try to translate
C struct bitfields into Go struct fields, even if their size can be
represented in Go. The order in which C bitfields appear in memory
is implementation dependent, so in some cases the cgo tool produced
results that were silently incorrect.
In real life, some system api like ebpf <linux/bpf.h> do has struct with bit fields.
structbpf_insn {
__u8code; /* opcode */__u8dst_reg:4; /* dest register */__u8src_reg:4; /* source register */__s16off; /* signed offset */__s32imm; /* signed immediate constant */
};
simply can't be represented as a Go struct. The cgo model has no way to handle C types that can't be represented in Go. The only mechanism we have is something like
simply can't be represented as a Go struct. The cgo model has no way to handle C types that can't be represented in Go. The only mechanism we have is something like
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
no
What did you do?
What did you expect to see?
go build passed
What did you see instead?
c.bf undefined (type *_Ctype_struct_foo has no field or method bf)
This is just a demo.
In https://go-review.googlesource.com/c/go/+/252378
In real life, some system api like ebpf <linux/bpf.h> do has struct with bit fields.
Related:
xlab/c-for-go#109
Maybe we should reconside it?
Thanks
CC @ianlancetaylor
The text was updated successfully, but these errors were encountered: