I have this function :
Tcl_Obj* cFuncTcl (Tcl_Interp* interp, Tcl_Obj* obj) {
Tcl_Obj *listObj = Tcl_NewListObj (0,NULL);
const char* var = Tcl_GetString(obj);
if (strcmp(var, "foo")) {
fprintf(stderr, "error\n");
exit(EXIT_FAILURE);
} else {
// Do something
}
return listObj;
}
I use return Tcl_ERROR; when my function returns an integer to report an error, but here my function returns an obj.
My question: Is there an API C Tcl equivalent to exit(EXIT_FAILURE)?
Reporting an error via its return value is not the same a
exit()which terminates the process. No TCL API is required to terminate the process, how would that be any different thanexit()?If you want to return from this function with an error indication rather then abort, then simply return NULL - the return value is a pointer or an object, not an object itself, so returning NULL is the idiomatic way of indicating failure.
The API is fully documented and there is process termination API that includes
Tcl_Exit(), but it is not clear that is what you actually need in this case. You seem to be conflating process termination with a function returning an error status. Nonetheless: