thanks you, the A3 community finaly help me to solve the last problem
* for index := C.int(0); index < argc; index++ { out =
append(out, C.GoString(*argv)) argv =
(**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset)) }*
I dont really understand why but it seems there was a problem with my
casting method with unsafe
*(*int)(unsafe.Pointer(limit)
Le dimanche 5 août 2018 15:02:47 UTC+2, Jan Mercl a écrit :
>
> On Sun, Aug 5, 2018 at 2:50 PM nicolas_boiteux via golang-nuts <
> [email protected] <javascript:>> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.