c-for-go icon indicating copy to clipboard operation
c-for-go copied to clipboard

need to access data in a C anonymous union...

Open danjenkins opened this issue 3 years ago • 0 comments

I need to access the data from a field in a C anonymous union within a struct (https://github.com/broadcastervc/ndigo/blob/master/include/Processing.NDI.structs.h#L235-L242) but I'm struggling to understand how I can make c for go output something I can use....

I tried putting my types.go file through go tool cgo -godefs types.go and replacing the types.go file with that as I'd read that I needed -godefs to make cgo understand those unions.... but I then realised I can't do that because code in cgo_helpers expects the types to be that of the C type defintion, not the full definition that the cgo tool then exports is...

Am I missing something?

The function I'm calling is this one: https://github.com/broadcastervc/ndigo/blob/master/ndigo.go#L129-L142

Theres also a separate issue where I pass in a referenced variable pVideoData which then gets made into a new Ref'd var for C cpVideoData - cpVideoData has new data from the C function.... but that never gets passed back into pVideoData.... cpVideoData/pVideoData is where I would expect to see LineStrideInBytes from the anonymous union....

Sorry, fairly new to Go and I've reached the end of my googling skills around cgo/c for go etc...

danjenkins avatar Jun 23 '22 18:06 danjenkins