On Sun, Aug 5, 2018 at 2:50 PM nicolas_boiteux via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> not sure to understand cause the iteration in your example is done on os
interface from golang not from c char array :(

Not sure what you mean by 'os interface'. Here's the part that iterates
**C.char, except pointers are transformed to uintptrs. Other that that it's
what you're, I think, after

// Xmain is defined at main.c:3:5
func Xmain(tls crt.TLS, _argc int32, _argv uintptr /* **int8 */) (r int32) {
var _p uintptr // **int8

_p = _argv
_1:
if (*(*uintptr)(unsafe.Pointer(_p))) == 0 {
goto _3
}

crt.Xprintf(tls, ts+0 /* "%s\n" */, *(*uintptr)(unsafe.Pointer(_p)))
_p += 8
goto _1

_3:
return r
}

Manually converting (untested again):

func foo(argv **C.char) []string {
        var a []string
        for p := argv; *p != nil; *(*uintptr)(unsafe.Pointer(p)) +=
unsafe.Sizeof(*p) {
                a = append(a, GoString(*p))
        }
        rerurn a
}


-- 

-j

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

Reply via email to