免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2344 | 回复: 1
打印 上一主题 下一主题

谁能告诉我预编译gcc -E .c文件,会有如下的信息,粗体代表什么意思? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-09-23 13:47 |只看该作者 |倒序浏览
1 # 1 "1.c"
  2 # 1 "<built-in>"
  3 # 1 "<command-line>"
  4 # 1 "1.c"
  5 # 1 "/usr/local/arm/4.2.2-eabi//usr/include/stdio.h" 1 3 4
  6 # 28 "/usr/local/arm/4.2.2-eabi//usr/include/stdio.h" 3 4
  7 # 1 "/usr/local/arm/4.2.2-eabi//usr/include/features.h" 1 3 4
  8 # 322 "/usr/local/arm/4.2.2-eabi//usr/include/features.h" 3 4
  9 # 1 "/usr/local/arm/4.2.2-eabi//usr/include/sys/cdefs.h" 1 3 4
10 # 324 "/usr/local/arm/4.2.2-eabi//usr/include/sys/cdefs.h" 3 4
11 # 1 "/usr/local/arm/4.2.2-eabi//usr/include/bits/wordsize.h" 1 3 4
12 # 325 "/usr/local/arm/4.2.2-eabi//usr/include/sys/cdefs.h" 2 3 4
13 # 323 "/usr/local/arm/4.2.2-eabi//usr/include/features.h" 2 3 4
14 # 345 "/usr/local/arm/4.2.2-eabi//usr/include/features.h" 3 4
15 # 1 "/usr/local/arm/4.2.2-eabi//usr/include/gnu/stubs.h" 1 3 4
16 # 346 "/usr/local/arm/4.2.2-eabi//usr/include/features.h" 2 3 4
17 # 29 "/usr/local/arm/4.2.2-eabi//usr/include/stdio.h" 2 3 4
18
19
20
21
22
23 # 1 "/usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/include/stddef.h" 1 3 4
24 # 214 "/usr/local/arm/4.2.2-eabi/usr/bin-ccache/../lib/gcc/arm-unknown-linux-gnueabi/4.2.2/include/stddef.h" 3 4
25 typedef unsigned int size_t;
. . . . . .

# 2 "1.c" 2
917
918 int main(void)
919 {
920  int i = 0;
921  printf("%d\n", i);
922 }

论坛徽章:
0
2 [报告]
发表于 2011-09-27 08:42 |只看该作者
#linenum filename flag
紧接着的内容源于filename文件,并且是filename文件的第linenum行开始的内容。
flag:
1: 开始一个新文件
2:回到文件
3:说明以下的内容是来自系统头文件
4:extern "C"

#1 "/usr/local/arm/4.2.2-eabi//usr/include/stdio.h" 1 3 4
下面的内容是stdio.h文件第1行起的内容,以下内容是一个新文件(即stdio.h)的内容,系统头文件,extern C

#2 "1.c" 2
以下内容为1.c的第2行,是回到某一文件(1.c) (从stdio.h回来的~~)

大概可以推断楼主的源文件为
1   #include <stdio.h>
2   
3   int main(void)
....

而用gcc -E 生成的.i文件中,源文件的第2行已变为了917行,中间插入了stdio.h所包含的内容。

---------------
Source file name and line number information is conveyed by lines of the form
# linenum filename flags
These are called linemarkers. They are inserted as needed into the output (but never within
a string or character constant). They mean that the following line originated in file filename
at line linenum. filename will never contain any non-printing characters; they are replaced
with octal escape sequences.
After the file name comes zero or more flags, which are ‘1’, ‘2’, ‘3’, or ‘4’. If there are
multiple flags, spaces separate them. Here is what the flags mean:
‘1’ This indicates the start of a new file.
‘2’ This indicates returning to a file (after having included another file).
‘3’ This indicates that the following text comes from a system header file, so certain
warnings should be suppressed.
‘4’ This indicates that the following text should be treated as being wrapped in an
implicit extern "C" block.
-----------------------------The C Preprocessor For gcc version 4.7.0 (pre-release)-----
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP