Re: [go-nuts] cgo Handle doc

2022-11-25 Thread Ian Lance Taylor
On Fri, Nov 25, 2022 at 12:45 PM Frédéric De Jaeger wrote: > > I was not asking for a conversion of a uintptr to an arbitrary pointer, that > would way too unsafe; but a conversion of uintptr to an arbitrary C pointer > (the same kind of typing rule that currently exists to allow casts back an

Re: [go-nuts] cgo Handle doc

2022-11-25 Thread Frédéric De Jaeger
On Friday, November 25, 2022 at 6:12:01 PM UTC+1 Ian Lance Taylor wrote: > On Fri, Nov 25, 2022 at 12:06 AM Frédéric De Jaeger > > > > Thanks for your reply. I was really missing an essential piece. > > I found a bit weird that you need to write a helper to pass a uintptr to > a void* C func

Re: [go-nuts] cgo Handle doc

2022-11-25 Thread Ian Lance Taylor
On Fri, Nov 25, 2022 at 12:06 AM Frédéric De Jaeger wrote: > > Thanks for your reply. I was really missing an essential piece. > I found a bit weird that you need to write a helper to pass a uintptr to a > void* C function. It could be nice to allow that > > func Foo(x uintptr) { > C.foo((*

Re: [go-nuts] cgo Handle doc

2022-11-25 Thread Frédéric De Jaeger
Given the *special cases* there https://pkg.go.dev/cmd/cgo#hdr-Special_cases, I would say this is not a good idea. On Friday, November 25, 2022 at 9:06:05 AM UTC+1 Frédéric De Jaeger wrote: > Thanks for your reply. I was really missing an essential piece. > I found a bit weird that you need to

Re: [go-nuts] cgo Handle doc

2022-11-25 Thread Frédéric De Jaeger
Thanks for your reply. I was really missing an essential piece. I found a bit weird that you need to write a helper to pass a uintptr to a void* C function. It could be nice to allow that func Foo(x uintptr) { C.foo((*C.char)x) } but unfortunately, the compiler does not seem to accept it.

Re: [go-nuts] cgo Handle doc

2022-11-23 Thread Ian Lance Taylor
On Wed, Nov 23, 2022 at 9:25 AM Frédéric De Jaeger wrote: > > There is something that puzzles me a lot in the doc about cgo.Handle there > https://pkg.go.dev/runtime/cgo. It says: > > Some C functions accept a void* argument that points to an arbitrary data > value supplied by the caller. It is