Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Preprocessor macro expansion

eldiener
New Contributor I
848 Views

Is there any compiler option for Intel C++ 17.0 which will show me the expansion of a preprocessor macro step-by-step when compiling a source file ?

I know that I can compile a complete source file's preprocessor output to a file, but I need to see each macro expansion step for a particular macro expansion of a source file to determine why the compiler is not expanding the macro properly.

0 Kudos
6 Replies
Varsha_M_Intel
Employee
848 Views

Hi,

If you are using linux, you can use -
icc -dM -E source.c

For windows:
icl /QdM /E source.c

Please let me know if it works.

Thanks,
Varsha

 

0 Kudos
Judith_W_Intel
Employee
848 Views

 

The dump macros option just dumps the macros -- it will not show you the macro expansions.

We do not have a switch that will show macros being expanded.

Judy

0 Kudos
jimdempseyatthecove
Honored Contributor III
848 Views

On Linux, you can get the sources to the C preprocessor. You can modify that to emit the macro line before and as it expands.

Someone may have done this, a little googling might find it.

Jim Dempsey

 

0 Kudos
eldiener
New Contributor I
848 Views

jimdempseyatthecove wrote:

On Linux, you can get the sources to the C preprocessor. You can modify that to emit the macro line before and as it expands.

Someone may have done this, a little googling might find it.

Jim Dempsey

 

Currently I am working with Intel C++ 17.0 on Windows. But even if I were working with Intel C++ on Linux I would have to rebuild the compiler. Both gcc and clang have ways to show a macro expansion so I was hoping Intel C++ would have it also.

0 Kudos
TimP
Honored Contributor III
848 Views

-E -P work similarly with icc as with g++.

0 Kudos
eldiener
New Contributor I
848 Views

Tim P. wrote:

-E -P work similarly with icc as with g++.

AFAIK -E -P shows complete macro expansion. I am looking for a means of showing step-by-step macro expansion for a particular macro.

 

0 Kudos
Reply