|
The NO_OUTPUT can be placed as the first token of the XSUB. This keyword indicates that
while the C subroutine we provide an interface to has a non-void return type, the
return value of this C subroutine should not be returned from the generated Perl subroutine.
With this keyword present The RETVAL Variable is
created, and in the generated call to the subroutine this variable is assigned to, but the
value of this variable is not going to be used in the auto-generated code.
This keyword makes sense only if RETVAL is going to be accessed by the
user-supplied code. It is especially useful to make a function interface more Perl-like,
especially when the C return value is just an error condition indicator. For example,
NO_OUTPUT int
delete_file(char *name)
POSTCALL:
if (RETVAL != 0)
croak("Error %d while deleting file '%s'", RETVAL, name);
|
|
Here the generated XS function returns nothing on success, and will die() with a meaningful
error message on error.
|
|