CheckLhs — C macro which checks the number of output arguments present in the calling Scilab function.
CheckLhs(nb_min_params,nb_max_params)
the minimum number of output arguments which must be present in the calling Scilab function
the maximum number of output arguments which must be present in the calling Scilab function
C macro which checks the number of output arguments present in the calling Scilab function. You must include stack-c.h to benefit from this function.
If the number of arguments is not between nb_min_params and
nb_max_params, we quit the C interface (return 0;
) and
an error is returned in the Scilab console.
Since CheckLhs
is doing a return
0;
within the gateway function, it is important to call this
macro before any memory allocation in order to avoid any memory
leak.
WARNING: This API is deprecated from Scilab 5.2.0 and is going to be removed with Scilab 6.0. Please use API Scilab (the new Scilab API).
In this example, the C gateway function checks for a number of output arguments which must be between 2 and 3.
#include <stack-c.h> int sci_mychecklhs(char * fname) { CheckLhs(2,3); return 0; }
Now, some functions testing this interface:
[A,B] = mychecklhs(); // OK, 2 output arguments [A,B,C] = mychecklhs(); // OK, 3 output arguments [A] = mychecklhs(); // ERROR, 1 output argument [A,B,C,D] = mychecklhs(); // ERROR, 4 output arguments