Skip to content

Instantly share code, notes, and snippets.

@copyninja
Created February 17, 2014 05:18
Show Gist options
  • Save copyninja/9045137 to your computer and use it in GitHub Desktop.
Save copyninja/9045137 to your computer and use it in GitHub Desktop.
Sample go program for cgo testing
package main
/*
#include "pointer.h"
*/
import "C"
import "fmt"
type SStruct struct {
s *C.SampleStruct
}
func main(){
var ss SStruct
fmt.Printf("Trying to read a structure by passing pointer\n")
C.GetSampleStruct(ss.s);
fmt.Printf("SampleStruct read!:\n")
fmt.Printf("a: %d b: %d c: %f",ss.s.a, ss.s.b, ss.s.c)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment