mex.h does not include config.h

Kris Thielemans kris.thielemans at imperial.ac.uk
Mon May 25 03:22:35 CDT 2009


Dear John

Answer below

> From: John W. Eaton [mailto:jwe at octave.org] 
> Sent: 20 May 2009 01:53
> To: Kris Thielemans
> Cc: bug at octave.org
> Subject: mex.h does not include config.h
> 
> On 19-May-2009, Kris Thielemans wrote:
> 
> | When using mex.h, I need to #include "config.h" to get my 
> files to compile
> | (using Octave 3.0.3). That seems unnecessary (and is 
> definitely not the case
> | in matlab). Therefore, I recommend to add a #include 
> "config.h" statement to
> | mex.h.
> 
> What do you need config.h for when compiling a MEX file with Octave?
> What fails if you don't?  I don't seem to need to include any config.h
> file when compiling a MEX function with "mkoctfile --mex" and Octave
> 3.0.5.
> 

I've copied the compilation errors I get below with a simplistic test file
(note: I haven't checked if this mexFunction actually works, I just copied
something from somewhere else and cut-out stuff irrelevant to this issue).
I'm using the cygwin version of octave 3.0.3. I could get rid of these by
#defining some stuff like HAVE_LIMITS_H etc myself, but that's obviously why
config.h is there.

Kris

----------- test.cc ---------------
/*#include <config.h>*/
#include <mex.h>
#include <matrix.h>


void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray*prhs[] )

{
    double in = mxGetScalar(prhs[0]);
    double *m_num;
    plhs[0]= mxCreateDoubleMatrix(1,1,mxREAL);    
    m_num = mxGetPr(plhs[0]);
    *m_num= in*2;
    return;
}

---------- output of "mkoctfile test.cc" -------------------
In file included from /usr/include/octave-3.0.3/octave/MatrixType.h:27,
                 from /usr/include/octave-3.0.3/octave/mx-base.h:29,
                 from /usr/include/octave-3.0.3/octave/matrix.h:31,
                 from test.cc:3:
/usr/include/octave-3.0.3/octave/oct-types.h:42:2: error: #error "CHAR_BIT
is not 8!"
/usr/include/octave-3.0.3/octave/oct-types.h:52:2: error: #error "No 2 byte
integer type found!"
/usr/include/octave-3.0.3/octave/oct-types.h:62:2: error: #error "No 4 byte
integer type found!"
In file included from /usr/include/octave-3.0.3/octave/dim-vector.h:30,
                 from /usr/include/octave-3.0.3/octave/Array.h:33,
                 from /usr/include/octave-3.0.3/octave/Array2.h:32,
                 from /usr/include/octave-3.0.3/octave/boolMatrix.h:27,
                 from /usr/include/octave-3.0.3/octave/mx-base.h:33,
                 from /usr/include/octave-3.0.3/octave/matrix.h:31,
                 from test.cc:3:
/usr/include/octave-3.0.3/octave/lo-error.h:30: error: expected initializer
before 'GCC_ATTR_NORETURN'
In file included from /usr/include/octave-3.0.3/octave/mx-inlines.cc:29,
                 from /usr/include/octave-3.0.3/octave/mx-op-defs.h:27,
                 from /usr/include/octave-3.0.3/octave/boolMatrix.h:30,
                 from /usr/include/octave-3.0.3/octave/mx-base.h:33,
                 from /usr/include/octave-3.0.3/octave/matrix.h:31,
                 from test.cc:3:
/usr/include/octave-3.0.3/octave/quit.h:69: error: expected initializer
before 'GCC_ATTR_NORETURN'
/usr/include/octave-3.0.3/octave/quit.h:97: error: expected initializer
before 'GCC_ATTR_NORETURN'
/usr/include/octave-3.0.3/octave/quit.h:99: error: expected initializer
before 'GCC_ATTR_NORETURN'
In file included from /usr/include/octave-3.0.3/octave/oct-inttypes.h:32,
                 from /usr/include/octave-3.0.3/octave/idx-vector.h:30,
                 from /usr/include/octave-3.0.3/octave/Array-util.h:30,
                 from /usr/include/octave-3.0.3/octave/Sparse-op-defs.h:27,
                 from /usr/include/octave-3.0.3/octave/boolSparse.h:29,
                 from /usr/include/octave-3.0.3/octave/mx-base.h:55,
                 from /usr/include/octave-3.0.3/octave/matrix.h:31,
                 from test.cc:3:
/usr/include/octave-3.0.3/octave/lo-ieee.h:67: error: expected initializer
before 'GCC_ATTR_DEPRECATED'
In file included from /usr/include/octave-3.0.3/octave/oct-inttypes.h:33,
                 from /usr/include/octave-3.0.3/octave/idx-vector.h:30,
                 from /usr/include/octave-3.0.3/octave/Array-util.h:30,
                 from /usr/include/octave-3.0.3/octave/Sparse-op-defs.h:27,
                 from /usr/include/octave-3.0.3/octave/boolSparse.h:29,
                 from /usr/include/octave-3.0.3/octave/mx-base.h:55,
                 from /usr/include/octave-3.0.3/octave/matrix.h:31,
                 from test.cc:3:
/usr/include/octave-3.0.3/octave/lo-mappers.h:44: error: expected
initializer before 'GCC_ATTR_DEPRECATED'



More information about the Bug-octave mailing list