1
0
mirror of https://github.com/golang/go synced 2024-11-25 01:47:56 -07:00

cgo: export unsafe.Pointer as void*

This will enable functions which use unsafe.Pointer as an argument
to be correctly exported by cgo.

R=rsc
CC=golang-dev
https://golang.org/cl/3849043
This commit is contained in:
Gustavo Niemeyer 2011-01-11 11:12:06 -05:00 committed by Russ Cox
parent 632be89407
commit 9f178edf51

View File

@ -606,6 +606,11 @@ func (p *Package) cgoType(e ast.Expr) *Type {
} }
return r return r
} }
case *ast.SelectorExpr:
id, ok := t.X.(*ast.Ident)
if ok && id.Name == "unsafe" && t.Sel.Name == "Pointer" {
return &Type{Size: p.PtrSize, Align: p.PtrSize, C: "void*"}
}
} }
error(e.Pos(), "unrecognized Go type %T", e) error(e.Pos(), "unrecognized Go type %T", e)
return &Type{Size: 4, Align: 4, C: "int"} return &Type{Size: 4, Align: 4, C: "int"}