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
package main
/*typedef struct Foo Foo;struct Foo { int Bar;};*/import"C"import"fmt"funcmain() {
f:=new(C.Foo)
f.Bar=C.int(5)
fmt.Println(f.Bar)
}
and now edit C code in the following way:
typedefstructFooFoo;
structFoo {
intBar : 1;
};
What did you expect to see?
everything should work
What did you see instead?
# command-line-arguments./main.go:14:4: f.Bar undefined (type *_Ctype_struct_Foo has no field or method Bar)./main.go:15:16: f.Bar undefined (type *_Ctype_struct_Foo has no field or method Bar)
The text was updated successfully, but these errors were encountered:
@ianlancetaylor well I don't insist on implementing bitfields in go, but these defined in C could be exported to GO anyway, couldn't they? If something exceeds bitfield size, C will throw panic, right?
How could they be exported to Go? The Go code that refers to these fields is ordinary Go code. The Go compiler is not a C compiler. The Go compiler does not support bitfields.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yep
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
consider the following code:
and now edit C code in the following way:
What did you expect to see?
everything should work
What did you see instead?
The text was updated successfully, but these errors were encountered: