2 ms·
The method proposed by the author does not work for packed structs. The btrfs library has a lot of them. main.go package main /* struct packed { uns
by laxk 11y ago
The method proposed by the author does not work for packed structs. The btrfs library has a lot of them.
main.go
package main
/*
struct packed {
unsigned char a;
unsigned long long b;
unsigned char c;
} __attribute__((packed));
*/
import "C"
type Packed C.struct_packed
go tool cgo -godefs main.go
package main
type Packed struct {
A uint8
Pad_cgo_0 [8]byte
C uint8
}
We lost packed.b field. Go doesn't support packed structs. More info here: https://groups.google.com/forum/#!topic/golang-nuts/UX5srUMtSSw https://groups.google.com/forum/#!topic/golang-nuts/UX5srUMt...