从宏生成和保存代码

Sat*_*bir 3 c++ macros c-preprocessor

我正在分析一个大量使用宏的遗留代码,我在理解宏如何在代码中扩展时迷失了.

可以任何人建议我一些工具或技术,以便我可以研究从宏扩展生成的实际代码.

平台:Windows XP
语言:C++
编译器:VC6

Che*_*evy 6

要将GCC作为预处理器运行,只需执行以下操作:

gcc -E source-file.cc > processed-source-file.cc
Run Code Online (Sandbox Code Playgroud)

它也会执行您可能想要或不想要的所有#includes.


cho*_*ida 5

使用visual studio,您可以使用Generate Preprocessed File选项.

在项目的属性中选择

C/C++/Preprocessor/
Run Code Online (Sandbox Code Playgroud)

在该选项卡中,有一个选项:

generate a preprocessed file.  
Run Code Online (Sandbox Code Playgroud)

选择是,带数字.