Hello Muppet,
Muppet wrote:
Hmm, on my understanding is that croak writes only to the console and do a exit to my perl module? But I want to have the error message back in my module, where
On Dec 6, 2004, at 4:21 AM, Reinhard Pagitsch wrote:
int _baar(IN x, OUT y, perror) int x; SV* y; SV* perror; PREINIT: char tmp1[256]; CODE: { if(!foo(x)) { sprintf(tmp1,"Wrong parameter!",); sv_setpvn(perror, tmp1, strlen(tmp1)); XPUSHs(sv_2mortal(newSViv(-1))); XSRETURN_IV(-1);
since your xsub is defined as returning a single value, you shouldn't need to use XPUSHs to make stack space -- it will already be there.
also, as i understand, XSRETURN_* will return immediately and will do the stack work for you, so the XPUSHs shouldn't be necessary.
third, that's not a very perlish failure. wouldn't it make more sense to croak() on that error? e.g.:
if (! foo (x)) croak ("Wrong parameter %d", x); /* does not return */
I can handle it propper. e.g. write a message in the status line of a Tk GUI from which the module was called.
I am wrong with that?
mit freundlichen Grüßen, with my best regards, Reinhard