针对vc,是否有类似预处理器一样的工具,能将源代码中的宏展开,得到展开后的代码。

cutegang 2006-12-29 02:35:18
比如#define Foo do {} while(0)

int main()
{
Foo;
}

如果有那种工具,就能将代码处理成
int main()
{
do {} while(0);
}

方便找错,以前同事演示过linux下的gcc有这样的功能,vc呢?有类似这样的工具吗?

...全文
255 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jim_King_2000 2006-12-30
  • 打赏
  • 举报
回复
有list文件的呀,看msdn怎么生成吧。
whoho 2006-12-30
  • 打赏
  • 举报
回复
cl /E
cl /EP
cl /P
三种可以用
请参考 cl /?
v2002750 2006-12-30
  • 打赏
  • 举报
回复
谢谢akirya(坏[其实偶不是什么所谓的坏人])
kouzhongling 2006-12-30
  • 打赏
  • 举报
回复
mfc 多文档 什么都不做 会生成一个超过 2m 的 .i文件
保证你会看晕^-^
kouzhongling 2006-12-30
  • 打赏
  • 举报
回复
cl /P a.cpp
会产生
a.i文件
hu_zy 2006-12-30
  • 打赏
  • 举报
回复
gcc 有 -E选项。。。vc不知道。
dx30611 2006-12-30
  • 打赏
  • 举报
回复
This option writes preprocessor output to a file with the same base name as the source file, but with the .I extension. It adds #line directives to the output file at the beginning and end of each included file and around lines removed by preprocessor directives that specify conditional compilation. The preprocessed listing file is identical to the original source file, except that all preprocessor directives are carried out, and macro expansions are performed.

输出到当前目录下.I后缀名的文件中
Ban999 2006-12-30
  • 打赏
  • 举报
回复
自己编写一个吧 用字符串替换
  • 打赏
  • 举报
回复
编译之后看你工程目录,好像在debug或者release目录下
扩展名是.i吧。
v2002750 2006-12-30
  • 打赏
  • 举报
回复
楼上,加上/P后,到哪里去找展开后的代码呢?
  • 打赏
  • 举报
回复
编译参数加上/P就可以了
v2002750 2006-12-30
  • 打赏
  • 举报
回复
顶一下,我看宏定义都快看晕了。

64,282

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧