I'd like to access the field of C union in Go. below is my source code, but i got an error when compile it:
package main
// #include <stdio.h>
// #include <stdlib.h>
// union bar {
// char c;
// int i;
// double d;
// };
import "C"
import "fmt"
func main() {
var b *C.union_bar = new(C.union_bar)
b.c = 4
fmt.Println(b)
}
when i build, i got errors like below:
b.c undefined (type *[8]byte has no field or method c)
Who could tell me the correct approach to access a union field?