g++ 预处理产生的中间文件后缀为什么不是.i

清钟沁桐 2011-02-24 11:55:56
对于一个普通的test.c文件
使用g++ -v -save-temps test.c -g -o test >& test.txt 进行编译处理,
发现预处理产生的中间文件名是test.ii ,而不是test.i ,难道编译器对于中间文件名后缀是没有约束的吗?

以下为中间预处理时使用的语句
/home/zyd/bin/gcc451/../libexec/gcc/i686-pc-linux-gnu/4.5.1/cc1plus -E -quiet -v -iprefix /home/zyd/bin/gcc451/../lib/gcc/i686-pc-linux-gnu/4.5.1/ -D_GNU_SOURCE test.c -mtune=generic -march=pentiumpro -g -fworking-directory -fpch-preprocess -o test.ii

...全文
286 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
清钟沁桐 2011-03-09
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 iambic 的回复:]

文件名有什么关系。用什么tmp_29988都可以。
[/Quote]

那就是这个不是标准?
iambic 2011-03-01
  • 打赏
  • 举报
回复
文件名有什么关系。用什么tmp_29988都可以。
justkk 2011-03-01
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zhongyunde 的回复:]
>& 就是不仅仅将标准流进行重定向,错误流也做重定向
[/Quote]
奇怪,我执行
ls >& a
提示a: bad file unit number
清钟沁桐 2011-03-01
  • 打赏
  • 举报
回复
>& 就是不仅仅将标准流进行重定向,错误流也做重定向
清钟沁桐 2011-02-25
  • 打赏
  • 举报
回复
hello.c
int puts(char *buf)
{
return 0;
}

int main(void)
{
char *str="Hello, Gcc Inline Assembly World!n";

__asm__ __volatile__ (
"pushl %%edx\n"
"call puts\n"
:
:"d"(str)
);

return 0;
}

刚才尝试使用gcc -v -save-temps hello.c -g -o hello >& hello.txt进行处理
预处理产生的中间文件名是hello.i.

其中相关的预处理命令:
/home/zyd/bin/gcc451/../libexec/gcc/i686-pc-linux-gnu/4.5.1/cc1 -E -quiet -v -iprefix /home/zyd/bin/gcc451/../lib/gcc/i686-pc-linux-gnu/4.5.1/ hello.c -mtune=generic -march=pentiumpro -g -fworking-directory -fpch-preprocess -o hello.i

综上所述,中间文件的后缀应该是不固定的

  • 打赏
  • 举报
回复
对于文件名当然没有约束了
justkk 2011-02-25
  • 打赏
  • 举报
回复
g++ .. >& test.txt
其中的>& 是什么意思?
如果单一个> 表示重定向输出到文件test.txt中

24,855

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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