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
I'm using a C library that manipulates a struct that has a field called type. I see no way to access the field without going through a wrapper function written in C.
Here's a fairly minimal example that reproduces the problem:
/*
struct foo {
int type;
};
*/
import "C"
func foo_type (x *C.struct_foo) int
return int(x.type);
}
The text was updated successfully, but these errors were encountered:
Within the Go file, C's struct field names that are keywords in Go can be accessed by prefixing them with an underscore: if x points at a C struct with a field named "type", x._type accesses the field. C struct fields that cannot be expressed in Go, such as bit fields or misaligned data, are omitted in the Go struct, replaced by appropriate padding to reach the next field or the end of the struct.
go version go1.10.1 linux/amd64
I'm using a C library that manipulates a struct that has a field called
type
. I see no way to access the field without going through a wrapper function written in C.Here's a fairly minimal example that reproduces the problem:
The text was updated successfully, but these errors were encountered: