Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mex compilation macro

Tags:

c++

matlab

mex

I wish to include a certain header file only when my code is compiled via the mex command in Matlab. If it's compiled directly with Visual Studio I do not want it included.

Is there a macro that can help with that?

I'd like to do something of this sort:

#ifdef MEX_COMPILE_FLAG
#include "mexDependent.h"
#end
like image 454
Leo Avatar asked May 30 '26 03:05

Leo


1 Answers

You can use the macro MATLAB_MEX_FILE for this. To get mex.h to work properly, this macro must be defined if and only if the compiled object will eventually be linked into a mex file. So the mex command makes sure to always define it when it calls the compiler.

like image 98
aschepler Avatar answered May 31 '26 17:05

aschepler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!