Created
January 8, 2015 16:12
-
-
Save kfei/53a680d53bea1bab9f4c to your computer and use it in GitHub Desktop.
Go: pass to C main
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
args := os.Args | |
arg := make([](*_Ctype_char), 0) | |
l := len(args) | |
for i, _ := range args { | |
char := C.CString(args[i]) | |
// defer C.free(unsafe.Pointer(char)) | |
strptr := (*_Ctype_char)(unsafe.Pointer(char)) | |
arg = append(arg, strptr) | |
} | |
C.cmain(C.int(l), (**_Ctype_char)(unsafe.Pointer(&arg[0]))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment