On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze <dean.w.schu...@gmail.com> wrote: > > I must be missing something pretty simple, but I have a C struct like this: > > typedef struct line > { > char hostname[HOSTNAME_MAX]; > char ip[IP_MAX]; > ... > } > > When I try to do the simple thing > > C.GoString(p.hostname)
An array of a fixed size within a C struct is a value (the same as in Go), but C.GoString expects a pointer to a C.char. Try `C.GoString(&p.hostname)`. Not tested. Note that if hostname is not properly zero terminated, your code will crash or misbehave. (Automatic array decay applies to C code, but not in Go.) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-X_mCYJA_SJ91d71QQFOO49vjJrUgp_SxvRnEN14HjQMQ%40mail.gmail.com.