Re: [go-nuts] Cgo Pointer Arithmetic

2016-09-01 Thread James Bardin
On Thursday, September 1, 2016 at 8:45:02 AM UTC-4, Luke Mauldin wrote: > > After I added the unsafe.Pointer conversion the code compiled: > https://play.golang.org/p/QTPyhZzKZH > > So my understanding is that line 15 is jut a pointer type conversion to > slice that is backed by the C array, so

Re: [go-nuts] Cgo Pointer Arithmetic

2016-09-01 Thread Luke Mauldin
After I added the unsafe.Pointer conversion the code compiled: https://play.golang.org/p/QTPyhZzKZH So my understanding is that line 15 is jut a pointer type conversion to slice that is backed by the C array, so it doesn't matter if I choose 1 << 20 entries or 1 << 22 entries, in both cases the

Re: [go-nuts] Cgo Pointer Arithmetic

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 2:06 PM, Luke Mauldin wrote: > I modified my example based on the code example you gave at the bottom for > the pointer arithmetic and that compiled without any go vet errors. I > attempted to use the slice whose backing array is the C array > https://play.golang.org/p/rJo

Re: [go-nuts] Cgo Pointer Arithmetic

2016-08-31 Thread Luke Mauldin
I modified my example based on the code example you gave at the bottom for the pointer arithmetic and that compiled without any go vet errors. I attempted to use the slice whose backing array is the C array https://play.golang.org/p/rJoDMu5YAQ but I get a compile error: main.go:14: cannot conve

Re: [go-nuts] Cgo Pointer Arithmetic

2016-08-31 Thread Ian Lance Taylor
On Wed, Aug 31, 2016 at 12:47 PM, Luke Mauldin wrote: > > I have questions about pointer arithmetic illustrated by this Play example: > https://play.golang.org/p/-cZteTY_M2 > > Questions: > 1) Is this the best way to do pointer arithmetic in Go to process a C array > and convert it to a Go slice?

[go-nuts] Cgo Pointer Arithmetic

2016-08-31 Thread Luke Mauldin
I have questions about pointer arithmetic illustrated by this Play example: https://play.golang.org/p/-cZteTY_M2 Questions: 1) Is this the best way to do pointer arithmetic in Go to process a C array and convert it to a Go slice? 2) Go vet gives an error on line 18 but doesn't give much informa