]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: clarify the underscore prefix rule and C union representation in Go.
authorShenghou Ma <minux.ma@gmail.com>
Thu, 11 Jul 2013 20:34:04 +0000 (04:34 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Thu, 11 Jul 2013 20:34:04 +0000 (04:34 +0800)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/10981043

src/cmd/cgo/doc.go

index 701ac6f8d919a00c07b6d3f81cc8856803da3899..17f01c313ee5c59f6a7c2fa09945891d3d017dd8 100644 (file)
@@ -49,7 +49,7 @@ to the flags derived from these directives.  Package-specific flags should
 be set using the directives, not the environment variables, so that builds
 work in unmodified environments.
 
-Within the Go file, C identifiers or field names that are keywords in Go
+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.
 
@@ -63,6 +63,9 @@ The C type void* is represented by Go's unsafe.Pointer.
 To access a struct, union, or enum type directly, prefix it with
 struct_, union_, or enum_, as in C.struct_stat.
 
+As Go doesn't have support for C's union type in the general case,
+C's union types are represented as a Go byte array with the same length.
+
 Go structs cannot embed fields with C types.
 
 Any C function (even void functions) may be called in a multiple