void HandleError(char *func, int numArgs, int errorArg, SV *errorSV, int errorCode) { if (numArgs==errorArg+1 && !SvREADONLY(errorSV)) { // new interface: set return code sv_setiv(errorSV, errorCode); } else { // old interface: die with error code and deprecation notification croak("%s() failed with error %d. The interface now has an additional optional argument.", func, errorCode); } }