GCC编译过程.docx
- 文档编号:3506899
- 上传时间:2022-11-23
- 格式:DOCX
- 页数:16
- 大小:18.58KB
GCC编译过程.docx
《GCC编译过程.docx》由会员分享,可在线阅读,更多相关《GCC编译过程.docx(16页珍藏版)》请在冰豆网上搜索。
GCC编译过程
GCC词法分析,语法分析,语义分析
答案:
一、gcc编译过程分为四段:
预处理、编译、汇编、链接
预处理:
gcc-Ehello.c-ohello.i
●参数-E表示只进行预处理或者也可以使用以下指令完成预处理过程。
●将所有的#define删除,并且展开所有的宏定义
●处理所有的条件预编译指令,比如#if,#ifdef,#elif,#else,#endif等。
●处理#include预编译指令,将被包含的文件插入到该预编译指令的位置。
●删除所有注释“//”和”/**/”.
●添加行号和文件标识,以便编译时产生调试用的行号及编译错误警告行号。
●保留所有的#pragma编译器指令,因为编译器需要使用它们。
预处理结果:
#1"hello.c"
#1"
#1"<命令行>"
#1"hello.c"
#1"/usr/include/stdio.h"134
#28"/usr/include/stdio.h"34
#1"/usr/include/features.h"134
#363"/usr/include/features.h"34
#1"/usr/include/sys/cdefs.h"134
#372"/usr/include/sys/cdefs.h"34
#1"/usr/include/bits/wordsize.h"134
#373"/usr/include/sys/cdefs.h"234
#364"/usr/include/features.h"234
#387"/usr/include/features.h"34
#1"/usr/include/gnu/stubs.h"134
#1"/usr/include/bits/wordsize.h"134
#5"/usr/include/gnu/stubs.h"234
#1"/usr/include/gnu/stubs-32.h"134
#8"/usr/include/gnu/stubs.h"234
#388"/usr/include/features.h"234
#29"/usr/include/stdio.h"234
#1"/usr/lib/gcc/i686-redhat-linux/4.6.2/include/stddef.h"134
#212"/usr/lib/gcc/i686-redhat-linux/4.6.2/include/stddef.h"34
typedefunsignedintsize_t;
#35"/usr/include/stdio.h"234
#1"/usr/include/bits/types.h"134
#28"/usr/include/bits/types.h"34
#1"/usr/include/bits/wordsize.h"134
#29"/usr/include/bits/types.h"234
typedefunsignedchar__u_char;
typedefunsignedshortint__u_short;
typedefunsignedint__u_int;
typedefunsignedlongint__u_long;
typedefsignedchar__int8_t;
typedefunsignedchar__uint8_t;
typedefsignedshortint__int16_t;
typedefunsignedshortint__uint16_t;
typedefsignedint__int32_t;
typedefunsignedint__uint32_t;
__extension__typedefsignedlonglongint__int64_t;
__extension__typedefunsignedlonglongint__uint64_t;
__extension__typedeflonglongint__quad_t;
__extension__typedefunsignedlonglongint__u_quad_t;
#131"/usr/include/bits/types.h"34
#1"/usr/include/bits/typesizes.h"134
#132"/usr/include/bits/types.h"234
__extension__typedef__u_quad_t__dev_t;
__extension__typedefunsignedint__uid_t;
__extension__typedefunsignedint__gid_t;
__extension__typedefunsignedlongint__ino_t;
__extension__typedef__u_quad_t__ino64_t;
__extension__typedefunsignedint__mode_t;
__extension__typedefunsignedint__nlink_t;
__extension__typedeflongint__off_t;
__extension__typedef__quad_t__off64_t;
__extension__typedefint__pid_t;
__extension__typedefstruct{int__val[2];}__fsid_t;
__extension__typedeflongint__clock_t;
__extension__typedefunsignedlongint__rlim_t;
__extension__typedef__u_quad_t__rlim64_t;
__extension__typedefunsignedint__id_t;
__extension__typedeflongint__time_t;
__extension__typedefunsignedint__useconds_t;
__extension__typedeflongint__suseconds_t;
__extension__typedefint__daddr_t;
__extension__typedeflongint__swblk_t;
__extension__typedefint__key_t;
__extension__typedefint__clockid_t;
__extension__typedefvoid*__timer_t;
__extension__typedeflongint__blksize_t;
__extension__typedeflongint__blkcnt_t;
__extension__typedef__quad_t__blkcnt64_t;
__extension__typedefunsignedlongint__fsblkcnt_t;
__extension__typedef__u_quad_t__fsblkcnt64_t;
__extension__typedefunsignedlongint__fsfilcnt_t;
__extension__typedef__u_quad_t__fsfilcnt64_t;
__extension__typedefint__ssize_t;
typedef__off64_t__loff_t;
typedef__quad_t*__qaddr_t;
typedefchar*__caddr_t;
__extension__typedefint__intptr_t;
__extension__typedefunsignedint__socklen_t;
#37"/usr/include/stdio.h"234
#45"/usr/include/stdio.h"34
struct_IO_FILE;
typedefstruct_IO_FILEFILE;
#65"/usr/include/stdio.h"34
typedefstruct_IO_FILE__FILE;
#75"/usr/include/stdio.h"34
#1"/usr/include/libio.h"134
#32"/usr/include/libio.h"34
#1"/usr/include/_G_config.h"134
#15"/usr/include/_G_config.h"34
#1"/usr/lib/gcc/i686-redhat-linux/4.6.2/include/stddef.h"134
#16"/usr/include/_G_config.h"234
#1"/usr/include/wchar.h"134
#83"/usr/include/wchar.h"34
typedefstruct
{
int__count;
union
{
unsignedint__wch;
char__wchb[4];
}__value;
}__mbstate_t;
#21"/usr/include/_G_config.h"234
typedefstruct
{
__off_t__pos;
__mbstate_t__state;
}_G_fpos_t;
typedefstruct
{
__off64_t__pos;
__mbstate_t__state;
}_G_fpos64_t;
#53"/usr/include/_G_config.h"34
typedefint_G_int16_t__attribute__((__mode__(__HI__)));
typedefint_G_int32_t__attribute__((__mode__(__SI__)));
typedefunsignedint_G_uint16_t__attribute__((__mode__(__HI__)));
typedefunsignedint_G_uint32_t__attribute__((__mode__(__SI__)));
#33"/usr/include/libio.h"234
#53"/usr/include/libio.h"34
#1"/usr/lib/gcc/i686-redhat-linux/4.6.2/include/stdarg.h"134
#40"/usr/lib/gcc/i686-redhat-linux/4.6.2/include/stdarg.h"34
typedef__builtin_va_list__gnuc_va_list;
#54"/usr/include/libio.h"234
#172"/usr/include/libio.h"34
struct_IO_jump_t;struct_IO_FILE;
#182"/usr/include/libio.h"34
typedefvoid_IO_lock_t;
struct_IO_marker{
struct_IO_marker*_next;
struct_IO_FILE*_sbuf;
int_pos;
#205"/usr/include/libio.h"34
};
enum__codecvt_result
{
__codecvt_ok,
__codecvt_partial,
__codecvt_error,
__codecvt_noconv
};
#273"/usr/include/libio.h"34
struct_IO_FILE{
int_flags;
char*_IO_read_ptr;
char*_IO_read_end;
char*_IO_read_base;
char*_IO_write_base;
char*_IO_write_ptr;
char*_IO_write_end;
char*_IO_buf_base;
char*_IO_buf_end;
char*_IO_save_base;
char*_IO_backup_base;
char*_IO_save_end;
struct_IO_marker*_markers;
struct_IO_FILE*_chain;
int_fileno;
int_flags2;
__off_t_old_offset;
unsignedshort_cur_column;
signedchar_vtable_offset;
char_shortbuf[1];
_IO_lock_t*_lock;
#321"/usr/include/libio.h"34
__off64_t_offset;
#330"/usr/include/libio.h"34
void*__pad1;
void*__pad2;
void*__pad3;
void*__pad4;
size_t__pad5;
int_mode;
char_unused2[15*sizeof(int)-4*sizeof(void*)-sizeof(size_t)];
};
typedefstruct_IO_FILE_IO_FILE;
struct_IO_FILE_plus;
externstruct_IO_FILE_plus_IO_2_1_stdin_;
externstruct_IO_FILE_plus_IO_2_1_stdout_;
externstruct_IO_FILE_plus_IO_2_1_stderr_;
#366"/usr/include/libio.h"34
typedef__ssize_t__io_read_fn(void*__cookie,char*__buf,size_t__nbytes);
typedef__ssize_t__io_write_fn(void*__cookie,__constchar*__buf,
size_t__n);
typedefint__io_seek_fn(void*__cookie,__off64_t*__pos,int__w);
typedefint__io_close_fn(void*__cookie);
#418"/usr/include/libio.h"34
externint__underflow(_IO_FILE*);
externint__uflow(_IO_FILE*);
externint__overflow(_IO_FILE*,int);
#462"/usr/include/libio.h"34
externint_IO_getc(_IO_FILE*__fp);
externint_IO_putc(int__c,_IO_FILE*__fp);
externint_IO_feof(_IO_FILE*__fp)__attribute__((__nothrow__));
externint_IO_ferror(_IO_FILE*__fp)__attribute__((__nothrow__));
externint_IO_peekc_locked(_IO_FILE*__fp);
externvoid_IO_flockfile(_IO_FILE*)__attribute__((__nothrow__));
externvoid_IO_funlockfile(_IO_FILE*)__attribute__((__nothrow__));
externint_IO_ftrylockfile(_IO_FILE*)__attribute__((__nothrow__));
#492"/usr/include/libio.h"34
externint_IO_vfscanf(_IO_FILE*__restrict,constchar*__restrict,
__gnuc_va_list,int*__restrict);
externint_IO_vfprintf(_IO_FILE*__restrict,constchar*__restrict,
__gnuc_va_list);
extern__ssize_t_IO_padn(_IO_FILE*,int,__ssize_t);
externsize_t_IO_sgetn(_IO_FILE*,void*,size_t);
extern__off64_t_IO_seekoff(_IO_FILE*,__off64_t,int,int);
extern__off64_t_IO_seekpos(_IO_FILE*,__off64_t,int);
externvoid_IO_free_backup_area(_IO_FILE*)__attribute__((__nothrow__));
#76"/usr/include/stdio.h"234
typedef__gnuc_va_listva_list;
#91"/usr/include/stdio.h"34
typedef__off_toff_t;
#103"/usr/include/stdio.h"34
typedef__ssize_tssize_t;
typedef_G_fpos_tfpos_t;
#165"/usr/include/stdio.h"34
#1"/usr/include/bits/stdio_lim.h"134
#166"/usr/include/stdio.h"234
externstruct_IO_FILE*stdin;
externstruct_IO_FILE*stdout;
externstruct_IO_FILE*stderr;
externintremove(__constchar*__filename)__attribute__((__nothrow__));
externintrename(__constchar*__old,__constchar*__new)__attribute__((__nothrow__));
externintrenameat(int__oldfd,__constchar*__old,int__newfd,
__constchar*__new)__attribute__((__nothrow__));
externFILE*tmpfile(void);
#212"/usr/include/stdio.h"34
externchar*tmpnam(char*__s)__attribute__((__nothrow__));
externchar*tmpnam_r(char*__s)__attribute__((__nothrow__));
#230"/usr/include/stdio.h"34
externchar*tempnam(__constchar*__dir,__constchar*__pfx)
__attribute__((__nothrow__))__attribute__((__malloc__));
externintfclose(FILE*__stream);
externintfflush(FILE*__stream);
#255"/usr/include/stdio.h"34
externintfflush_unlocked(FILE*__stream);
#269"/usr/include/stdio.h"34
externFILE*fopen(__constchar*__restrict__filename,
__constchar*__restrict__modes);
externFILE*freopen(__constchar*__restrict__filename,
__constchar*__restrict__modes,
FILE*__restrict__stream);
#298"/usr/include/stdio.h"34
#309"/usr/include/stdio.h"34
externFILE*fdopen(int__fd,__constchar*__modes)__attribute__((__nothrow__));
#322"/usr/include/stdio.h"34
externFILE*fmemopen(void*__s,size_t__len,__constchar*__modes)
__attribute__((__nothrow__));
externFILE*open_memstream(char**__bufloc,size_t*__sizeloc)__attribute__((__nothrow__));
externvoidsetbuf(FILE*__restrict__stream,char*__restrict__buf)__attribute__((__nothrow__));
externintsetvbuf(FILE*__restrict
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- GCC 编译 过程