• <tfoot id='q2Dxs'></tfoot>
    <legend id='q2Dxs'><style id='q2Dxs'><dir id='q2Dxs'><q id='q2Dxs'></q></dir></style></legend>

      1. <small id='q2Dxs'></small><noframes id='q2Dxs'>

        <i id='q2Dxs'><tr id='q2Dxs'><dt id='q2Dxs'><q id='q2Dxs'><span id='q2Dxs'><b id='q2Dxs'><form id='q2Dxs'><ins id='q2Dxs'></ins><ul id='q2Dxs'></ul><sub id='q2Dxs'></sub></form><legend id='q2Dxs'></legend><bdo id='q2Dxs'><pre id='q2Dxs'><center id='q2Dxs'></center></pre></bdo></b><th id='q2Dxs'></th></span></q></dt></tr></i><div id='q2Dxs'><tfoot id='q2Dxs'></tfoot><dl id='q2Dxs'><fieldset id='q2Dxs'></fieldset></dl></div>
          <bdo id='q2Dxs'></bdo><ul id='q2Dxs'></ul>

        C++程序的编译阶段有哪些?

        What are the stages of compilation of a C++ program?(C++程序的编译阶段有哪些?)

              • <bdo id='d6nsV'></bdo><ul id='d6nsV'></ul>
              • <small id='d6nsV'></small><noframes id='d6nsV'>

                <i id='d6nsV'><tr id='d6nsV'><dt id='d6nsV'><q id='d6nsV'><span id='d6nsV'><b id='d6nsV'><form id='d6nsV'><ins id='d6nsV'></ins><ul id='d6nsV'></ul><sub id='d6nsV'></sub></form><legend id='d6nsV'></legend><bdo id='d6nsV'><pre id='d6nsV'><center id='d6nsV'></center></pre></bdo></b><th id='d6nsV'></th></span></q></dt></tr></i><div id='d6nsV'><tfoot id='d6nsV'></tfoot><dl id='d6nsV'><fieldset id='d6nsV'></fieldset></dl></div>
                <tfoot id='d6nsV'></tfoot>

                    <tbody id='d6nsV'></tbody>
                1. <legend id='d6nsV'><style id='d6nsV'><dir id='d6nsV'><q id='d6nsV'></q></dir></style></legend>
                  本文介绍了C++程序的编译阶段有哪些?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  C++ 程序的编译阶段是否由标准规定?

                  Are the stages of compilation of a C++ program specified by the standard?

                  如果有,它们是什么?

                  如果没有,一个广泛使用的编译器的答案(我更喜欢 MSVS)会很棒.

                  If not, an answer for a widely-used compiler (I'd prefer MSVS) would be great.

                  我说的是预处理、标记化、解析等.它们的执行顺序是什么?它们具体做什么?

                  I'm talking about preprocessing, tokenization, parsing and such. What is the order in which they are executed and what do they do in particular?

                  我知道编译、链接和预处理的作用,我最感兴趣的是其他和顺序.当然,也欢迎对这些进行解释,因为我可能不是唯一对答案感兴趣的人.

                  I know what compilation, linking and preprocessing do, I'm mostly interested in the others and the order. Explanations for these are, of course, also welcomed since I might not be the only one interested in an answer.

                  推荐答案

                  C++ 程序的编译阶段是否由标准规定?

                  Are the stages of compilation of a C++ program specified by the standard?

                  是和否.

                  C++ 标准定义了 9 个翻译阶段".引用 N3242 草案 (10MBPDF),日期为 2011-02-28(在官方 C++11 标准发布之前),第 2.2 节:

                  The C++ standard defines 9 "phases of translation". Quoting from the N3242 draft (10MB PDF), dated 2011-02-28 (prior to the release of the official C++11 standard), section 2.2:

                  翻译语法规则之间的优先级由以下阶段指定[见脚注].

                  The precedence among the syntax rules of translation is specified by the following phases [see footnote].

                  1. 物理源文件字符以实现定义的方式映射到基本源字符集(为行尾指示符引入换行符)如果必要的.[SNIP]
                  2. 每个反斜杠字符 () 后面紧跟一个换行符的实例都被删除,将物理源行拼接为形成逻辑源代码行.[SNIP]
                  3. 源文件被分解为预处理标记 (2.5) 和空白字符序列(包括注释).[SNIP]
                  4. 执行预处理指令,扩展宏调用,并执行 _Pragma 一元运算符表达式.[SNIP]
                  5. 字符文字或字符串文字中的每个源字符集成员,以及每个转义序列和通用字符名称在字符文字或非原始字符串文字中,转换为执行字符集的对应成员;[SNIP]
                  6. 连接相邻的字符串文字标记.
                  7. 分隔标记的空白字符不再重要.每个预处理令牌都被转换为一个令牌.(2.7).这结果标记在句法和语义上进行分析和翻译为翻译单元.[SNIP]
                  8. 翻译的翻译单元和实例化单元的组合如下:[SNIP]
                  9. 解析所有外部实体引用.链接库组件以满足对未定义的实体的外部引用当前翻译.所有这些翻译输出都被收集到一个包含执行所需信息的程序映像执行环境.

                  [footnote] 实现必须表现得好像这些单独的阶段发生一样,尽管在实践中不同的阶段可能会折叠在一起.

                  [footnote] Implementations must behave as if these separate phases occur, although in practice different phases might be folded together.

                  正如 [SNIP] 标记所示,我没有引用整个部分,只是足以让大家理解.

                  As indicated by the [SNIP] markers, I haven't quoted the entire section, just enough to get the idea across.

                  强调一下,编译器不需要遵循这个确切的模型,只要最终结果就像他们那样.

                  To emphasize, compilers are not required to follow this exact model, as long as the final result is as if they did.

                  阶段 1-6 或多或少对应于预处理器,7 阶段与您通常认为的编译相关,8 阶段处理模板,9 阶段对应链接.

                  Phases 1-6 correspond more or less to the preprocessor, 7 to what you might normally think of as compilation, 8 deals with templates, and 9 corresponds to linking.

                  (C 的翻译阶段类似,但省略了 #8.)

                  (C's translation phases are similar, but #8 is omitted.)

                  这篇关于C++程序的编译阶段有哪些?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Type(::x); valid?(是类型(::x);有效的?)
                  Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                  Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                  Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                  No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                  Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)
                2. <tfoot id='HScoE'></tfoot>

                3. <small id='HScoE'></small><noframes id='HScoE'>

                      <tbody id='HScoE'></tbody>

                      <legend id='HScoE'><style id='HScoE'><dir id='HScoE'><q id='HScoE'></q></dir></style></legend>
                      <i id='HScoE'><tr id='HScoE'><dt id='HScoE'><q id='HScoE'><span id='HScoE'><b id='HScoE'><form id='HScoE'><ins id='HScoE'></ins><ul id='HScoE'></ul><sub id='HScoE'></sub></form><legend id='HScoE'></legend><bdo id='HScoE'><pre id='HScoE'><center id='HScoE'></center></pre></bdo></b><th id='HScoE'></th></span></q></dt></tr></i><div id='HScoE'><tfoot id='HScoE'></tfoot><dl id='HScoE'><fieldset id='HScoE'></fieldset></dl></div>

                          <bdo id='HScoE'></bdo><ul id='HScoE'></ul>