Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Preprocessor macro expansion

eldiener
New Contributor I
273 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
273 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

 

Judith_W_Intel
Employee
273 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

jimdempseyatthecove
Black Belt
273 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

 

eldiener
New Contributor I
273 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.

TimP
Black Belt
273 Views

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

eldiener
New Contributor I
273 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.

 

Reply