On Thu, Apr 30, 2020 at 8:17 PM Dean Schulze <
dean.w....@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.)