Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cgo: exported function doesn't support pointer to array arguments #10889

Closed
minux opened this issue May 17, 2015 · 1 comment
Closed

cmd/cgo: exported function doesn't support pointer to array arguments #10889

minux opened this issue May 17, 2015 · 1 comment
Milestone

Comments

@minux
Copy link
Member

minux commented May 17, 2015

package p
import "C"
//export F
func F(x *[10]C.int) {}
$ go build issue10889.go
# command-line-arguments
./issue10889.go:6:11: Go type not supported in export: [10]_Ctype_int
./issue10889.go:6:11: Go type not supported in export: [10]_Ctype_int

We can't support [10]_Ctype_int as argument, that's for sure, but why
can't we support *[10]_Ctype_int as argument?

I imagine one reason is probably that the C pointer to array layout and
Go's are incompatible, but I don't think that is the case today. Now people
need to resort to passing pointers to Go exported functions, but that also
assumes that the array layout is compatible between C and Go.

@minux minux added this to the Go1.6 milestone May 17, 2015
@rsc
Copy link
Contributor

rsc commented Oct 16, 2015

C doesn't have array arguments nor pointer-to-array arguments. It just has pointers.
I suppose we could turn Go *[10]C.int into C int**, but there's already Go **C.int for that.
In general arrays in argument position are not well understood by most C programmers.
Given that there is already an equivalent syntax supported (plain pointers), I'm not inclined
to do anything here.

@rsc rsc closed this as completed Oct 16, 2015
@golang golang locked and limited conversation to collaborators Oct 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants