Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-31 Thread George Hartzell
George Hartzell writes: > > Quick summary, I'm trying to understand the Go structures that cgo > gives me, how they map back onto the C structures and why a Go struct > that doesn't quite match the cgo output seems to work anyway. > [...] Ian gave me a lot of good things to chew on, but

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-31 Thread George Hartzell
Ian Lance Taylor writes: > [...] > OK, that is true. Since your program will be using cgo, even though > you aren't calling any C functions, it will be dynamically linked by > default. You could try using "go build -ldflags=-extldflags=-static". > I don't know whether it will work. > To

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread George Hartzell
George Hartzell writes: > [...] > ``` > i2c/i2c.go:15:9: cannot use [0] (type *byte) as type *_Ctype_uchar > in assignment > ``` > > I can't come up with any cast that makes the compiler happy. I'm also > unsure whether that line runs afoul of this commandment: *Go code may > not store

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread Ian Lance Taylor
On Fri, Aug 30, 2019 at 4:57 PM George Hartzell wrote: > > Ian Lance Taylor writes: > > On Thu, Aug 29, 2019 at 6:26 PM George Hartzell > wrote: > > [...] > > There is another approach, which is to use import "C", and then write code > like > > > > const IoctlConstant = C.IoctlConstant >

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread George Hartzell
Ian Lance Taylor writes: > On Thu, Aug 29, 2019 at 6:26 PM George Hartzell wrote: > [...] > There is another approach, which is to use import "C", and then write code > like > > const IoctlConstant = C.IoctlConstant > type GoIoctlType = C.CIoctlType > > and then use those types in

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-30 Thread Ian Lance Taylor
On Thu, Aug 29, 2019 at 6:26 PM George Hartzell wrote: > > I suppose I *could* write a cgo library that would wrap the C-based > [i2c-tools] library, but I wanted to do it directly in Go, without > adding the [i2c-tools] dependency. > > Or, are you saying that I should create a package that does

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-29 Thread George Hartzell
Ian Lance Taylor writes: > On Thu, Aug 29, 2019 at 5:15 PM George Hartzell wrote: > > > > Quick summary, I'm trying to understand the Go structures that cgo > > gives me, how they map back onto the C structures and why a Go struct > > that doesn't quite match the cgo output seems to work

Re: [go-nuts] Help understanding mapping Go<->C structures across IOCTL's

2019-08-29 Thread Ian Lance Taylor
On Thu, Aug 29, 2019 at 5:15 PM George Hartzell wrote: > > Quick summary, I'm trying to understand the Go structures that cgo > gives me, how they map back onto the C structures and why a Go struct > that doesn't quite match the cgo output seems to work anyway. > > I've called out two explicit