]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cgo: document that structs and arrays don't work with //export
authorIan Lance Taylor <iant@golang.org>
Wed, 2 Aug 2017 19:30:58 +0000 (12:30 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 8 Aug 2017 04:39:05 +0000 (04:39 +0000)
Fixes #18412

Change-Id: Ib457eeced7820517aa35df9e7dfda1c0de4ac004
Reviewed-on: https://go-review.googlesource.com/52852
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/cgo/doc.go
src/cmd/cgo/out.go

index b2388829a8796aca2a9fa97ac105fef7fe48d446..bed2ab44c7f4bee26045297356536e07b6c2d31d 100644 (file)
@@ -241,7 +241,10 @@ They will be available in the C code as:
 found in the _cgo_export.h generated header, after any preambles
 copied from the cgo input files. Functions with multiple
 return values are mapped to functions returning a struct.
+
 Not all Go types can be mapped to C types in a useful way.
+Go struct types are not supported; use a C struct type.
+Go array types are not supported; use a C pointer.
 
 Using //export in a file places a restriction on the preamble:
 since it is copied into two different C output files, it must not
index 9ab6bd8f977b33e27f4abdea7f0fb262f406a6d6..228f981c9427898b65bfce5b4ea96648f2f6b1db 100644 (file)
@@ -1223,8 +1223,9 @@ func (p *Package) cgoType(e ast.Expr) *Type {
                        // Slice: pointer, len, cap.
                        return &Type{Size: p.PtrSize * 3, Align: p.PtrSize, C: c("GoSlice")}
                }
+               // Non-slice array types are not supported.
        case *ast.StructType:
-               // TODO
+               // Not supported.
        case *ast.FuncType:
                return &Type{Size: p.PtrSize, Align: p.PtrSize, C: c("void*")}
        case *ast.InterfaceType: