Why can't Mex C/C++ Code With Xcode on Mac (MatlabR2015a)?

I tried to follow this example to know how to use the Legacy Code Tool :
But when I try to use the function legacy_code to create the S-function and the corresponding C MEX with this command :
% legacy_code('compile', def);
I get this error :
% ### Start Compiling ex_sfun_doubleit
mex('-I/Users/..../Desktop/example', '-c', '-outdir', '/private/tmp/tpaa85b6f5_b2e5_4c61_8c6e_17849ff9c5bb', '/Users/..../Desktop/example/doubleIt.c')
Building with 'Xcode with Clang'.
Error using mex
In file included from /Users/..../Desktop/example/doubleIt.c:1:
/Users/nabil/Desktop/example/doubleIt.h:1:2: error: invalid preprocessing directive
#ifndef_DOUBLEIT_H_
^
/Users/...../Desktop/example/doubleIt.h:2:2: error: invalid preprocessing directive
#define_DOUBLEIT_H_
^
/Users/...../Desktop/example/doubleIt.h:6:2: error: #endif without #if
#endif
^
3 errors generated.
Error in legacycode.LCT/compile (line 352)
Error in legacycode.LCT.legacyCodeImpl (line 84)
Error in legacy_code (line 87)
[varargout{1:nargout}] = legacycode.LCT.legacyCodeImpl(action, varargin{1:end});
I notice Im on Mac OSX Elcapitan 10.11 and Matlab R2015a.
Thanks.

 Respuesta aceptada

James Tursa
James Tursa el 28 de Abr. de 2017
There are no spaces between the directive and the token. So change these lines
#ifndef_DOUBLEIT_H_
#define_DOUBLEIT_H_
to these:
#ifndef _DOUBLEIT_H_
#define _DOUBLEIT_H_

Más respuestas (0)

Categorías

Productos

Etiquetas

Preguntada:

el 28 de Abr. de 2017

Respondida:

el 28 de Abr. de 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by