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
If there is a zero-length array at the end of a C struct which contains other fields, then cgo omits the field from the Go view of the C struct in $WORKDIR/.../_cgo_gotypes.go
But if the zero-length array is the only field in the struct then cgo keeps it. And if the zero-length array isn't last it keeps it.
In other words the code below fails to compile with the error
./tst27.go:19: t2.x undefined (type C.struct_T2 has no field or method x)
which is somewhat strange given that it is happy with the reference to the very similar t1.x.
package main
/*
struct T1 {
char x[0];
};
struct T2 {
int i;
char x[0];
};
*/
import "C"
func main() {
var t1 C.struct_T1
_ = t1.x
var t2 C.struct_T2
_ = t2.x
}
(Also since Go is fine with zero-length arrays in Go structs I don't see why cgo is omitting T2.x)
The text was updated successfully, but these errors were encountered:
When a C struct ends with a zero-sized field, but the struct itself is not zero-sized, Go code can no longer refer to the zero-sized field. Any such references will have to be rewritten.
go version go1.5.2 linux/amd64
If there is a zero-length array at the end of a C struct which contains other fields, then cgo omits the field from the Go view of the C struct in $WORKDIR/.../_cgo_gotypes.go
But if the zero-length array is the only field in the struct then cgo keeps it. And if the zero-length array isn't last it keeps it.
In other words the code below fails to compile with the error
./tst27.go:19: t2.x undefined (type C.struct_T2 has no field or method x)
which is somewhat strange given that it is happy with the reference to the very similar t1.x.
(Also since Go is fine with zero-length arrays in Go structs I don't see why cgo is omitting T2.x)
The text was updated successfully, but these errors were encountered: