[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mxIs* functions now return bool
From: |
Rik |
Subject: |
mxIs* functions now return bool |
Date: |
Sat, 10 Sep 2016 22:29:07 -0700 |
9/10/16
I've been working on improving the MEX interface in Octave. One of the
things I noticed is that the predicate tests in Matlab are all returning a
bool, whereas in Octave they return an int. A predicate test might be
something like mxIsScalar or mxIsComplex. Does anyone see a problem with
changing the function prototypes to return bool?
extern OCTINTERP_API int mxIsComplex (const mxArray *ptr);
=>
extern OCTINTERP_API bool mxIsComplex (const mxArray *ptr);
One of the things I don't understand is that the C language didn't have a
bool type until C99, and even then it was necessary to #include <stdbool.h>
in order to access it. However, I accidentally coded mxIsScalar to return
bool and it has compiled correctly. The only thing I see at the top of
mexproto.h is
#if defined (__cplusplus)
# include <cstdlib>
extern "C" {
#else
# include <stdlib.h>
#endif
When I run 'mex -v ...' I can see that the compiler is gcc, not g++, so I
don't think the first branch is being taken. Should I worry and add the
include for stdbool.h when compiling with a straight C compiler?
--Rik
- mxIs* functions now return bool,
Rik <=