If I define the same  2 struct in c and go
can they be  passed directly with unsafe.Pointer
and how to export go struct from go to c ?   

/*
#include <stdio.h>

typedef struct {
    int a;
    int b;
} Foo;

void pass_struct(Foo *in) { printf("%d : %d\n", in->a, in->b); }

*/

import "C"
import (
    "fmt"
    "unsafe")

type Foo struct{ a, b int32 }

C.pass_struct((*C.Foo)(unsafe.Pointer(&foo)))

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