xlab / c-for-go

Automatic C-Go Bindings Generator for Go Programming Language
https://c.for-go.com
MIT License
1.47k stars 116 forks source link

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

Open danjenkins opened 2 years ago

danjenkins commented 2 years ago

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...