I have to call a C function from Go. The C function is taking a 2d integer array and some other parameters. I struggling with passing a Go 2d integer array through C function.
I have created the go array as type C.int and pass into the c function. it shows :
cannot use G (type [10][10]_Ctype_int) as type *[10]_Ctype_int in argument to _Cfunc_dijkstra
Here dijkstra function is implemented inside merge_sort.c file
package main
// #include "merge_sort.c"
import "C"
func main(){
var G = [10][10] C.int {
{0, 3, 4, 0, 0, 0, 0, 0, 0, 0},
{3, 0, 0, 4, 5, 0, 0, 0, 0, 0},
{4, 0, 0, 4, 0, 6, 0, 0, 0, 0},
{0, 4, 4, 0, 5, 3, 7, 0, 0, 0},
{0, 5, 0, 5, 0, 0, 4, 0, 6, 0},
{0, 0, 6, 3, 0, 0, 3, 3, 0, 0},
{0, 0, 0, 7, 4, 3, 0, 2, 1, 3},
{0, 0, 0, 0, 0, 3, 2, 0, 0, 3},
{0, 0, 0, 0, 6, 0, 1, 0, 0, 3},
{0, 0, 0, 0, 0, 0, 3, 3, 3, 0},
}
var n C.int= 10
var u C.int= 0
C.dijkstra(G, n ,u)
}
The c function looks like this
void dijkstra(int G[10][10],int n,int startnode);