suppose I have a macro, like
#define max(a,b) (((a) > (b)) ? (a) : (b))
then I use it in the "normal code"
int foo()
{
...
c = max(a,b);
...
}
Is there a way to see the code after precompiling? Does exist a way to see the effect of macro substituion (maybe done by compiler, I use gcc)?
I'd like to get something like this:
int foo()
{
...
c = ((a>b) ? a : b);
...
}
Is there something like this?
You want to see the preprocessed source code. Usually your C compiler has a switch to output the preprocessed output.
For gcc, it's gcc -E [C-filename]
.
For msvc, it's cl /EP
or cl /P
. See MSVC /P (Preprocess to a File)
Use cpp
, the GCC C preprocessor.
gcc
is only a collection of tools: cpp
, cc
and ld
for examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With