Skip to content

Instantly share code, notes, and snippets.

@mtfelian
Last active June 3, 2020 08:05
Show Gist options
  • Save mtfelian/4c2b1a9b8b3b4001413fd09554cb63bc to your computer and use it in GitHub Desktop.
Save mtfelian/4c2b1a9b8b3b4001413fd09554cb63bc to your computer and use it in GitHub Desktop.
How to fill and pass C struct from Go
options := &C.GDALGridLinearOptions{dfRadius: C.double(-1.0), dfNoDataValue: C.double(0.0)}
C.someCall(unsafe.Pointer(options))
options := (*C.GDALGridLinearOptions)(C.malloc(C.size_t(C.sizeof_GDALGridLinearOptions)))
defer C.free(unsafe.Pointer(options))
(*options).dfRadius = C.double(-1.0)
(*options).dfNoDataValue = C.double(0.0)
C.someCall(unsafe.Pointer(options))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment