On Mon, Nov 6, 2017 at 10:59 AM, Chun Zhang <chunzh...@gmail.com> wrote: > > Sorry about the confusion! My gocode set the value of the device and then > pass it to C++ code. > > Code goes like this: > > device := "eth1" // hardcoding this value works or retrieving it from Flag > as below > > flag.StringVar(&device, "Device", "eth1", "NIC to Listen")
It would help if you showed a complete standalone example, but I think I see what you mean. This works because the current compiler produces a string literal for "eth1" that is stored in the program itself. The internal string pointer points into the program text segment, and so it is not a Go pointer, and so you do not get the error. A Go *string is still not a C char**, but I guess that a *string does look like C struct { char *p; uintptr_t n; }*, so since you are passing only a single string it may be working by accident. Note that the Go string is not necessarily NUL-terminated, but perhaps in this case it happens to be. Ian -- 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. For more options, visit https://groups.google.com/d/optout.