E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
GCC-3.4.6
GCC-3.4.6
源代码学习笔记(38)
4.1.3.1.2.3.1.1. #pragmainterface及#pragmaimplementation作为GCC提供的一个C++的扩展,【6】解释了#pragmainterface“filename”(op)及#pragmaimplementation“filename”(op)。6.3模糊链接性(VagueLinkage)在C++中有一些构造要求在目标文件中分配空间,但又不明
wuhui_gdnt
·
2010-04-29 10:00
Studying note of
GCC-3.4.6
source (37)
4.1.3.1.2.2. ReadincommonfileBackshould_stack_file,forcommonfile,thewholefilecontentwillbeputintobufferofcpp_reader. should_stack_file(continue) 584 if(!read_file(pfile,file))585 returnfal
wuhui_gdnt
·
2010-04-28 09:00
File
buffer
input
include
optimization
preprocessor
GCC-3.4.6
源代码学习笔记(37)
4.1.3.1.2.2. 读入普通文件回到should_stack_file,对于普通文件,整个文件内容将被放入cpp_reader的buffer内。 should_stack_file(continue) 584 if(!read_file(pfile,file))585 returnfalse;586 587 /*Nowwe'vereadthefile'sco
wuhui_gdnt
·
2010-04-28 09:00
File
null
buffer
input
include
optimization
Studying note of
GCC-3.4.6
source (36)
4.1.3.1.2.1.4.4.3. TheexpansionbodyInmacroexpansionbody,hash‘#’onlycanimmediatelyprecedethemacroparametertostringifyit.Otherwiseitonlycanappearfreelyinassemblerlanguageascomment.CLK_ASMatline1431willb
wuhui_gdnt
·
2010-04-27 09:00
GCC-3.4.6
源代码学习笔记(36)
4.1.3.1.2.1.4.4.3. 宏展开体在宏展开体中,#仅能紧贴在宏参数前,已使其字符串化。另外它还能作为注释自由地出现在汇编语言中。在1431行的CLK_ASM被选项–lang-asm设置,该选项指示编译器直接处理汇编输入。 create_iso_definition(continue) 1408 if(macro->fun_like)1409 token=lex_expansio
wuhui_gdnt
·
2010-04-27 09:00
struct
File
buffer
token
macros
whitespace
GCC-3.4.6
源代码学习笔记(35)
4.1.3.1.2.1.4.4. 创建宏定义–ISO模式我们已经看到,标准模式是基于符号(token)的,因此对于每个看到的符号,都要以下面的形式保存其信息。 175 structcpp_token incpplib.
wuhui_gdnt
·
2010-04-26 09:00
buffer
token
Comments
optimization
macros
whitespace
Studying note of
GCC-3.4.6
source (34)
4.1.3.1.2.1.4. ReadinmacrodefintionsInrestofPCHfile,itcontainsdetailofdefinitionofmacros.Bythisinformation,wecaninsertthosedefintionsincpp_readernow.InPCHfile,everydefinitionbeginswithmacr
wuhui_gdnt
·
2010-04-23 09:00
GCC-3.4.6
源代码学习笔记(34)
4.1.3.1.2.1.4. 读入宏定义在剩下的PCH文件中,包含了其宏定义的细节。根据这个信息,现在我们可以把这些定义插入cpp_reader里。在PCH文件中,每个宏定义以以下的macrodef_struct结构开头。 38 structmacrodef_struct
wuhui_gdnt
·
2010-04-23 09:00
c
struct
buffer
token
macros
newline
Studying note of
GCC-3.4.6
source (33)
4.1.3.1.2.1.2. ReadinPCHcontentinintermediateformBefore,wehaveseensomevariablesaredeclaredwithGTY((…)),theprogramofGC(garbagecollection)willparsespecifiedfiles(GTY((…))isnotparsedoutsideth
wuhui_gdnt
·
2010-04-22 09:00
struct
File
null
Arrays
macros
variables
GCC-3.4.6
源代码学习笔记(33)
4.1.3.1.2.1.2. 读入中间形式的PCH内容之前,我们已经看到一些变量在声明中使用了GTY((…)),GC程序(垃圾回收器)将解析指定的文件(在指定列表外的文件中的GTY((…))是不被解析的,它们将导致编译错误——未定义的识别符),并将结果输出到加上gt-前缀的同名文件中。而该文件才作为编译编译器时的真正输入。因此,以下所涉及的变量才是编译器真正使用的,它们来自
wuhui_gdnt
·
2010-04-22 09:00
linux
struct
File
null
编译器
fold
Studying note of
GCC-3.4.6
source (32)
4.1.3.1.2. ReadinfileAboveatline439,ifthefilehasbeenfoundandopenedsuccessfully, _cpp_find_filereturnsthecorresponding_cpp_fileobject,andreferedbypfile->main_file.Soatthispoint,itcanbeginread
wuhui_gdnt
·
2010-04-21 09:00
GCC-3.4.6
源代码学习笔记(32)
4.1.3.1.2. 读入文件上面439行,如果文件找到并成功打开,_cpp_find_file将对应的_cpp_file对象返回,交由pfile->main_file保存。由此,可以开始读入文件的内容。 cpp_read_main_file(continue) 473 _cpp_stack_file(pfile,pfile->main_file,false);474
wuhui_gdnt
·
2010-04-21 09:00
Studying note of
GCC-3.4.6
source (31)
4.1.3.1.1.1. ValidatePCHFileIfPCHfileisfound,itneedsensurethisfileisvalid. 1257staticbool1258validate_pch(cpp_reader*pfile,_cpp_file*file,constchar*pchname) incppfiles.c1259{1260 constchar
wuhui_gdnt
·
2010-04-20 09:00
GCC-3.4.6
源代码学习笔记(31)
4.1.3.1.1.1. 验证PCH文件如果PCH文件找到了,需确保它是有效的。 1257staticbool1258validate_pch(cpp_reader*pfile,_cpp_file*file,constchar*pchname) incppfiles.c1259{1260 constchar*saved_path=file->path;1261 boolv
wuhui_gdnt
·
2010-04-20 09:00
String
struct
File
preprocessor
Pointers
combinations
Studying note of
GCC-3.4.6
source (30)
4.1.3.ReadinsourcefileAsnowcpp_readerisready,itistimetoreadinsourcefiles.Below,macroinput_lineaccesseslinefieldofglobalvariableinput_locationwhichrecordsthecurrentfilenameandcurrenthandlinglinenumber.
wuhui_gdnt
·
2010-04-19 10:00
GCC-3.4.6
源代码学习笔记(30)
4.1.3.读入源代码现在cpp_reader已经就绪,是时候读入源文件了。在下面,宏input_line访问全局变量input_location的line域。这个全局变量记录了当前文件名及当前处理行号。 c_common_post_option(continue) 1162 saved_lineno=input_line;1163 input_line=0;11641165 /*Ifane
wuhui_gdnt
·
2010-04-19 10:00
struct
File
search
buffer
Path
include
Studying note of
GCC-3.4.6
source (29)
4.1.2.SetupflagscontrollinglexerBelow,flag_inline_trees,itis0ifweshouldnotperforminlining,1ifweshouldexpandfunctionscallsinlineatthetreelevel,and2ifweshouldconsiderallfunctionstobeinlinecandidates.And
wuhui_gdnt
·
2010-04-16 09:00
struct
tree
compiler
output
initialization
filenames
GCC-3.4.6
源代码学习笔记(29)
4.1.2.设置Lexer控制参数下面,flag_inline_trees,是0如果不执行内联,是1如果以树形式展开内联函数调用,是2如果所有函数被视为内联的候选。而flag_inline_functions,如果为非0值,允许编译器在调用点,选择某些简单的内联函数将其内联。这个变量自动被-O3打开,除非指定了-fno-inline-functions。另flag_no_inline如果为非0值,
wuhui_gdnt
·
2010-04-16 09:00
struct
tree
编译器
output
Warnings
filenames
Studying note of
GCC-3.4.6
source (28)
4.1.1.FinishthesetupofsearchpathGCClooksinseveraldifferentplacesforheaders.OnanormalUnixsystem,ifyoudonotinstructitotherwise,itwilllookforheadersrequestedwith`#include'in: /usr/local/include LIB
wuhui_gdnt
·
2010-04-15 09:00
struct
search
System
Path
include
Duplicates
GCC-3.4.6
源代码学习笔记(28)
4.1.1.完成查找路径设置GCC在多个不同的地方查找头文件。在一个普通的Unix系统上,如果不另外指示,由`#include'请求的文件将在以下目录中查找: /usr/local/include LIBDIR/gcc/TARGET/VERSION/include /usr/TARGET/include /usr/include对于C++程序,它还首先会在/usr/incl
wuhui_gdnt
·
2010-04-15 09:00
JOIN
struct
System
Path
include
Duplicates
Studying note of
GCC-3.4.6
source (27)
3.3.4.FinishthehandlingWhenreturnfromhandle_options,decode_optionsupdatesotherflagsaccordingly.Orinigalvalueofflag_no_inlineandflag_really_no_inlineare2.Ifappropriate,flag_no_inlinewillbesetas1incommo
wuhui_gdnt
·
2010-04-14 09:00
GCC-3.4.6
源代码学习笔记(27)
3.3.4.完成处理当从handle_options符号时,decode_options相应地更新其他标识。flag_no_inline和flag_really_no_inline初始是2。如果合适,flag_no_inline将被common_handle_option设为1(见该函数的1060行)。在下面,可以看到,如果内联是可能的,这2个变量均是0。而且如果optimize是0,flag_n
wuhui_gdnt
·
2010-04-14 09:00
Studying note of
GCC-3.4.6
source (26 cont2)
common_handle_option(continue) 1179 caseOPT_fprofile:1180 profile_flag=value;1181 break;11821183 caseOPT_fprofile_arcs:1184 profile_arc_flag_set=true;1185 profile_arc_flag=va
wuhui_gdnt
·
2010-04-13 12:00
Studying note of
GCC-3.4.6
source (26 cont1)
common_handle_option(continue) 909 caseOPT_fcall_used_:910 fix_register(arg,0,1);911 break;912 913 caseOPT_fcall_saved_:914 fix_register(arg,0,0);915 break;916 917 caseOPT
wuhui_gdnt
·
2010-04-13 12:00
Studying note of
GCC-3.4.6
source (26)
3.3.3.1.2. HandlingcommonoptionsForcommonswitchesorswitchescan’tbefinishedbyc_common_handle_option,common_handle_optionisinvoked. 655 staticint656 common_handle_option(size_tscode,constchar*
wuhui_gdnt
·
2010-04-08 12:00
GCC-3.4.6
源代码学习笔记(26)
3.3.3.1.2. 处理公用选项对于公用选项及c_common_handle_option未能完成处理之选项,则需要继续调用common_handle_option。 655 staticint656 common_handle_option(size_tscode,constchar*arg, inopts.c6
wuhui_gdnt
·
2010-04-08 11:00
fortran
compiler
deprecated
branch
loops
optimization
Studying note of
GCC-3.4.6
source (25 cont2)
c_common_handle_option(continue) 657 caseOPT_Wwrite_strings:658 if(!c_dialect_cxx())659 flag_const_strings=value;660 else661 warn_write_strings=value;662 break;663 664
wuhui_gdnt
·
2010-04-07 11:00
Studying note of
GCC-3.4.6
source (25 cont1)
c_common_handle_option(continue) 401 caseOPT_Wbad_function_cast:402 warn_bad_function_cast=value;403 break;404 405 caseOPT_Wcast_qual:406 warn_cast_qual=value;407 break;408 40
wuhui_gdnt
·
2010-04-07 11:00
function
deprecated
initialization
macros
Warnings
preprocessor
Studying note of
GCC-3.4.6
source (25)
3.3.3.1.1. OptionsforC++ForC/C++orobj-C,handle_optionsoflang_hooksisthesameasc_common_handle_option.Inbelow,OPT_*isusedasindexintocl_options. 251 int252 c_common_handle_option(size_tscode,co
wuhui_gdnt
·
2010-04-07 11:00
function
header
File
dependencies
Warnings
preprocessor
GCC-3.4.6
源代码学习笔记(25续2)
c_common_handle_option(continue) 657 caseOPT_Wwrite_strings:658 if(!c_dialect_cxx())659 flag_const_strings=value;660 else661 warn_write_strings=value;662 break;663 664
wuhui_gdnt
·
2010-04-07 11:00
c
Path
编译器
templates
statistics
enums
GCC-3.4.6
源代码学习笔记(25续1)
c_common_handle_option(continue) 401 caseOPT_Wbad_function_cast:402 warn_bad_function_cast=value;403 break;404 405 caseOPT_Wcast_qual:406 warn_cast_qual=value;407 break;408 40
wuhui_gdnt
·
2010-04-07 11:00
Studying note of
GCC-3.4.6
source (24 cont)
-foptimize-sibling-callsRefertoflag_optimize_sibling_callsCL_COMMON-foptional-diagsEnableoptionaldiagnosticsCL_CXX|CL_ObjCXX-fpack-structRefertoflag_pack_structCL_COMMON-fpcc-struct-returnRefertoflag_
wuhui_gdnt
·
2010-04-01 12:00
c
Integer
include
profiling
Constants
Instantiation
Studying note of
GCC-3.4.6
source (24)
3.3.3.1. UsableoptionsThisarrayisinitializedinoptions.candtheinitializingvalueisdisplayedinfollowingtable.Itisalonglist.Formoredetails,refersto[6],[8].Notethattheentitiesareorderedbytheirnames.Optio
wuhui_gdnt
·
2010-04-01 12:00
GCC-3.4.6
源代码学习笔记(24续)
-fnonansi-builtins参见flag_no_nonansi_builtinCL_CXX|CL_ObjCXX-fnonnull-objects已过时,不支持CL_CXX|CL_ObjCXX-fold-unroll-all-loops参见flag_old_unroll_all_loopsCL_COMMON-fold-unroll-loops参见flag_old_unroll_loopsCL
wuhui_gdnt
·
2010-04-01 12:00
GCC-3.4.6
源代码学习笔记(24)
3.3.3.1. 可用的选项这个数组在options.c文件中初始化,其初始化值在下表中给出。这是个很长的列表。更详细的描述,可参见【8】,【6】。注意,选项是按名字排序的。选项 描述标识集--help显示帮助信息CL_COMMON--output-pch=参见pch_fileCL_C|CL_CXX|CL_ObjC|CL_ObjCXX|CL_JOINED|CL_SEPARATE--param=
wuhui_gdnt
·
2010-04-01 12:00
Studying note of
GCC-3.4.6
source (23)
3.3.3.HandlingotheroptionsNoweverythingisready,it’stimetohandleoptionsotherthan–O,theoptimizationoption. decode_options(continue) 618 handle_options(argc,argv,lang_mask);619 620 if(flag_pie)621 f
wuhui_gdnt
·
2010-03-31 11:00
GCC-3.4.6
源代码学习笔记(23)
3.3.3.处理其他选项一切准备好后,可以开始处理除-O优化选项外的编译命令行选项了。 decode_options(continue) 618 handle_options(argc,argv,lang_mask);619 620 if(flag_pie)621 flag_pic=flag_pie;622 if(flag_pic&&!flag_pie)623 flag_shli
wuhui_gdnt
·
2010-03-31 11:00
struct
tree
command
input
语言
编译器
Studying note of
GCC-3.4.6
source (22)
3.3.2.InitializingoptionsrelatedtotargetAtline605above,set_target_switchhandlesoptionsrelatedtocompiletarget.Alltheseoptionsbeginswith“-m”. 3829void3830set_target_switch(constchar*name)
wuhui_gdnt
·
2010-03-30 11:00
Math
String
struct
asynchronous
optimization
returning
GCC-3.4.6
源代码学习笔记(22)
3.3.2.初始化与目标平台相关选项在上面605行,set_target_switch处理与目标平台相关的选项。所有这些选项都以“-m”开头。 3829void3830set_target_switch(constchar*name) intoplev.c3831{3832 size_t
wuhui_gdnt
·
2010-03-30 11:00
String
struct
平台
asynchronous
64bit
optimization
Studying note of
GCC-3.4.6
source (21)
3.3.Handlingswitches3.3.1.OptionsrelatedtooptimizationBacktodecode_options,atline480,forC++,initialize_diagnosticsinlang_hookspointstocxx_initialize_diagnostics.Itsetupsdiagnosticsfacilitywhichwillgiv
wuhui_gdnt
·
2010-03-25 11:00
branch
alignment
optimization
loops
Allocation
Constants
GCC-3.4.6
源代码学习笔记(21)
3.3.处理编译选项3.3.1.与优化有关的选项回到decode_options,在480行,对于C++,lang_hooks中的钩子initialize_diagnostics引用cxx_initialize_diagnostics。它设立诊断设施,用于给出足够详细、正确的出错消息。这里我们跳过它,因为它与真正的编译关系不大。 decode_options(continue) 489 /*Sc
wuhui_gdnt
·
2010-03-25 11:00
优化
branch
loops
optimization
Diagnostics
enums
Studying note of
GCC-3.4.6
source (20)
3.2.2.PrepareforswitcheshandlingAftercreatingcpp_reader,c_common_init_optionsconfirmsthelanguagefinally;andinitializesrelateddatastructure.Thefunctionwillreturninformationaboutthelanguage. c_common_in
wuhui_gdnt
·
2010-03-24 11:00
exception
function
assembly
fortran
Warnings
Constants
GCC-3.4.6
源代码学习笔记(20)
3.2.2.准备处理编译命令选项在创建了cpp_reader对象后,c_common_init_options最后确认要编译的语言,并初始化相关的数据结构。这个函数最终将确认的语言返回。 c_common_init_options(continue) 210 cpp_opts=cpp_get_options(parse_in);211 cpp_opts->dollars_in_ident=DO
wuhui_gdnt
·
2010-03-24 11:00
数据结构
c
assembly
语言
fortran
Warnings
Studying note of
GCC-3.4.6
source (19 cont)
Fieldop_stackincpp_readeraimstohandlemultiple-includeoptimization(using#if!definedand#endiftoenclose#includedirective),itwillholdsthetokensofthe#ifor#elseifexpression. cpp_create_reader(continue) 199
wuhui_gdnt
·
2010-03-23 12:00
Studying note of
GCC-3.4.6
source (19)
3.2.1.Createcpp_readerAtline205above,cpp_create_readertriestocreateacpp_readerobject.ForlanguagerequirespreprocessorlikeCandC++,usuallycompilershouldprovideapasstopreprocessthesource.Butincurrentversi
wuhui_gdnt
·
2010-03-23 12:00
struct
buffer
token
character
include
Comments
GCC-3.4.6
源代码学习笔记(19续)
cpp_reader中的域op_stack用于多次包含优化(multiple-includeoptimization,即将#include指示加入#if!defined和#endif对中),它将缓存#if或#elseif表达式的符号。 cpp_create_reader(continue) 199 /*Theexpressionparserstack. */200 _cpp_expand_op
wuhui_gdnt
·
2010-03-23 11:00
struct
gcc
table
token
extension
whitespace
GCC-3.4.6
源代码学习笔记(19)
3.2.1.创建cpp_reader在上面的205行,cpp_create_reader尝试创建一个cpp_reader对象。对于象C,C++这样需要预处理机制的语言,一般来说,编译器需要提供一个预处理遍,对源程序进行预处理操作。而当前版本的GCC,应用cpp_reader对象,实现了在线的预处理展开,不再需要预处理遍。因为这个目的,cpp_reader的定义也变得相当复杂。在以后有关词法分析和解
wuhui_gdnt
·
2010-03-23 11:00
struct
buffer
token
character
include
Comments
Studying note of
GCC-3.4.6
source (18)
3. PreparationAccordingtoParsingOptions3.1.HooksforLangaugesBacktotoplev_main,aswementionedbefore,it’sappreciatethatfront-endcanmakenewlanguageintroducationeasy.InGCC,thefront-endprovidesthefame
wuhui_gdnt
·
2010-03-22 12:00
GCC-3.4.6
源代码学习笔记(18)
3. 对命令行选项的处理3.1.为语言准备的钩子回到toplev_main,就像我们以前提到过的,前端最好能设计成使新语言的引入变得容易。在GCC中,前端为语言提供了一个框架,在这个框架中,所有语言相关的处理都被定义为回调(callback),而且这些回调被捆绑至以下的结构中。 212 structlang_hooks
wuhui_gdnt
·
2010-03-22 11:00
struct
function
tree
hook
initialization
Diagnostics
Studying note of
GCC-3.4.6
source (17)
2.4.InitializeOptimizationParametersBacktogeneral_init,atline4264add_paramssaveselementsoflang_independent_paramsintocompiler_paramswhichcontainsthecompilerparametersandtheircurrentvalues.Arraylang_in
wuhui_gdnt
·
2010-03-19 11:00
上一页
1
2
3
4
5
6
7
8
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他