When I try to pass a C.int from package main
to a function in a helper package called common
, I get the following error:
main.go:24: cannot use argc (type C.int) as type common.C.int in argument to common.GoStrings
From common.go
:
/*
...
*/
import "C"
...
func GoStrings(argc C.int, argv **C.char) (args []string) {
// do stuff
}
From main.go
:
/*
#cgo LDFLAGS: -lpam -fPIC
#define PAM_SM_AUTH
#include <security/pam_appl.h>
*/
import "C"
...
func pam_sm_authenticate(pamh *C.pam_handle_t, flags, argc C.int, argv **C.char) C.int {
args := common.GoStrings(argc, argv)
...
}
Is there any way to pass these objects back and forth? I've tried type casting to e.g. common.C.int
, but that doesn't seem to be valid syntax. I'd like to be able to call GoStrings
from multiple different main programs, and it seems like that should be allowable.