Mercurial > octave
changeset 26973:2b23129f8a96
mex.m: Raise an error on failure when return value is not captured (bug #55990).
* mex.m: Document new behavior. Add new calling form of mex as a function.
Change name of output variable from "retval" to "status". Change internal
variable names "output" to "out" and "status" to "sts". If sts variable
is non-zero and no output was requested, emit an error.
author | Andrew Janke <andrew@apjanke.net> |
---|---|
date | Sun, 24 Mar 2019 15:19:56 -0400 |
parents | d164e70efbf6 |
children | aa50801747a9 |
files | scripts/miscellaneous/mex.m |
diffstat | 1 files changed, 20 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/mex.m Mon Mar 25 20:21:51 2019 +0100 +++ b/scripts/miscellaneous/mex.m Sun Mar 24 15:19:56 2019 -0400 @@ -17,22 +17,35 @@ ## <https://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {} mex [options] file @dots{} +## @deftypefn {} {} mex [-options] file @dots{} +## @deftypefnx {} {@code{status} =} mex (@dots{}) ## Compile source code written in C, C++, or Fortran, to a MEX file. ## -## This is equivalent to @code{mkoctfile --mex [options] file}. +## @var{status} is the return status of the @code{mkoctfile} function. +## +## If the compilation fails, and the output argument is not requested, +## an error is raised. If the programmer requests @var{status}, however, +## Octave will merely issue a warning and it is the programmer's responsibility +## to verify the command was successful. +## +## This is equivalent to @code{mkoctfile --mex [-options] file}. +## ## @seealso{mkoctfile, mexext} ## @end deftypefn -function retval = mex (varargin) +function status = mex (varargin) - [output, status] = mkoctfile ("--mex", varargin{:}); + [out, sts] = mkoctfile ("--mex", varargin{:}); - if (! isempty (output)) - printf ("%s", output); + if (! isempty (out)) + printf ("%s", out); endif if (nargout > 0) - retval = status; + status = sts; + else + if (sts != 0) + error ("mex: building exited with failure status\n"); + endif endif endfunction