Alex
Alex

Reputation: 175

Set #define in c code from Matlab

I have a Matlab program that uses and compiles C code. Now the C code uses a

defines.h

file containing all the defines for my source code. Now there is one define that is making trouble in Matlab and I would like to "deactivate" it whenever Matlab is compiling the .c files. I do not want to remove the define since I need it, when I compile my source code with gcc (without Matlab). Is there any way to "redefine" a value within the compilation process in Matlab?

Here is a code snippet of my compilation process from Matlab:

mex CFLAGS='$CFLAGS -Wall -Wextra -pedantic -std=c99 -DMATLAB_MEX' function.c

Thanks!

Upvotes: 0

Views: 196

Answers (1)

houtanb
houtanb

Reputation: 4100

Just make sure you have something like the following in defines.h

#ifndef MATLAB_MEX
  // code to "deactivate" when compling mex functions
#endif

Upvotes: 1

Related Questions