Chr*_*ris 6 pointers go cgo

我正在使用一个 C 库,与下面不同,我无法控制它。我需要将指向也包含指针的数组的指针传递给 C 函数。

package main

/*
#include <stdio.h>

typedef int* pInt;

void foo(pInt p[]) {
  printf("foo()\n");
}
*/
import "C"
import "unsafe"

func main() {
    var i C.int
    var p1 C.pInt = (*C.int)(unsafe.Pointer(&i))
    var p2 C.pInt = (*C.int)(unsafe.Pointer(&i))
    var ps []C.pInt = []C.pInt{p1, p2}
    C.foo(unsafe.Pointer(&ps[0]))
}
panic: runtime error: cgo argument has Go pointer to Go pointer