I am attempting to write a Go function that sends a string to a C function as a C.CString.
func AssertString(fact string) {
// sbytes := []byte(fact)
// ccp := (*C.char)(unsafe.Pointer(&sbytes[0]))
ccp := C.CString(fact)
C.EnvAssertString(C.env, ccp)
}
I tried both the commented out section and the currently used section and I get the following
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x30 pc=0x7431a9]
The C function EnvAssertString comes from the CLIPS Expert System library and looks like this:
globle void *EnvAssertString(void *theEnv, const char *theString)
{
struct fact *theFact;
int danglingConstructs;
danglingConstructs = ConstructData(theEnv)->DanglingConstructs;
if ((theFact = StringToFact(theEnv,theString)) == NULL) return(NULL);
if ((! CommandLineData(theEnv)->EvaluatingTopLevelCommand) &&
(EvaluationData(theEnv)->CurrentExpression == NULL))
{ ConstructData(theEnv)->DanglingConstructs = danglingConstructs; }
return((void *) EnvAssert(theEnv,(void *) theFact));
}
I am assuming it is how the Go generated char pointer is used but I'm not exactly sure. Anyone got some ideas?