Reputation: 382
I want to get the preprocessor output when compiling my c-code through mex of MATLAB using MinGW64 Compiler (C) so using gcc (right?). From this post I got that you can do this with pure gcc passing the option -E to gcc. However I installed gcc through MATLAB app and therefore cannot access it through command line (would also appreciate a command how to do that, without reinstalling MinGW64 and setting it up manually for use with MATLAB).
I tried to do the following assuming that compiler flags are the right way to pass the argument:
mex -c grampc_run.c -I../../include -I../include COMPFLAGS='$COMPFLAGS -E'
This just results in the creation of the object file.
Upvotes: 0
Views: 214
Reputation: 60484
COMPFLAGS
is used by the MSCV compiler. The GCC compiler loos at CFLAGS
and CXXFLAGS
(for C and C++ compilation, respectively). See here. Thus, you should use the following syntax:
mex -c grampc_run.c -I../../include -I../include CFLAGS='$CFLAGS -E'
You might also want to add the -v
option to mex
. GCC puts the preprocessor output to the standard output, which mex
might not show you. With -v
it does show you all the output.
Upvotes: 1