i found another thing.

func RVExtensionArgs(output *C.char, outputsize C.size_t, input *C.char, 
argv **C.char, argc C.int) {
    var offset = unsafe.Sizeof(uintptr(0))
    var out []string






*    limit := *(*int)(unsafe.Pointer(&argc))    if limit < 1000 {        
for index := 0; index < limit; index++ {            out = append(out, 
C.GoString(*argv))            argv = 
(**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(argv)) + offset))        
}    }*
    temp := fmt.Sprintf("Hello %s %d %s!", C.GoString(input), limit,  out)

    // Return a result to Arma
    result := C.CString(temp)
    defer C.free(unsafe.Pointer(result))
    var size = C.strlen(result) + 1
    if size > outputsize {
        size = outputsize
    }
    C.memmove(unsafe.Pointer(output), unsafe.Pointer(result), size)
}Saisissez le code ici...
it seems there is also a bug in the main program cause the argc variable, 
the first execution time contains a memory adress instead of int


Le dimanche 5 août 2018 15:47:00 UTC+2, nicolas...@yahoo.fr a écrit :
>
> Miki & Jan thanks
>
> i tested the both methods. Dll compiles normaly, but program crash.
>
> With Miki code the first time, i run the code, i saw that string array 
> contains also other characters that not come from argv.
>
> 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 <
>> golan...@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