English 中文(简体)
汇编C++方案的各个阶段是什么?
原标题:What are the stages of compilation of a C++ program?

标准是否具体规定了C++方案汇编阶段?

如果是的话,它们是什么?

www.un.org/Depts/DGACM/index_spanish.htm 如果没有,对广泛使用的汇编者的答复 (一) 更喜欢MSVS,,可能很伟大。

我谈论的是预处理、象征性化、 par等。 他们被处决的顺序是什么,特别是怎样做?

EDIT: 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++方案汇编阶段?

是的,不是。

C++标准界定了9个“翻译阶段”。 Quoting from N3242 draft (10MB PDF), dated 2011-02-28 (prior to the release of the official C++11 standard), section 2.2:

中文翻译规则的优先地位由以下阶段具体规定:[见脚注]

  1. Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set (introducing new-line characters for end-of-line indicators) if necessary. [SNIP]
  2. Each instance of a backslash character () immediately followed by a new-line character is deleted, splicing physical source lines to form logical source lines. [SNIP]
  3. The source file is decomposed into preprocessing tokens (2.5) and sequences of white-space characters (including comments). [SNIP]
  4. Preprocessing directives are executed, macro invocations are expanded, and _Pragma unary operator expressions are executed. [SNIP]
  5. Each source character set member in a character literal or a string literal, as well as each escape sequence and universal-character-name in a character literal or a non-raw string literal, is converted to the corresponding member of the execution character set; [SNIP]
  6. Adjacent string literal tokens are concatenated.
  7. White-space characters separating tokens are no longer significant. Each preprocessing token is converted into a token. (2.7). The resulting tokens are syntactically and semantically analyzed and translated as a translation unit. [SNIP]
  8. Translated translation units and instantiation units are combined as follows: [SNIP]
  9. All external entity references are resolved. Library components are linked to satisfy external references to entities not defined in the current translation. All such translator output is collected into a program image which contains information needed for execution in its execution environment.

[脚注] 执行必须与这些不同阶段的发生情况相同,尽管在实践中不同阶段可能同时进行。

[SNIP]标记所示,我只引述了整个部分,只是为了实现这一想法。

为了强调,只要最终结果与最终结果一样,汇编者就必须遵守这一准确模式。

第六至六个阶段与前处理人大致相同,第七阶段与你通常认为的汇编内容相对应,8阶段涉及模板,9阶段与链接。

(C) 翻译阶段类似,但第8号删除。)

问题回答

所谓的“翻译阶段”列于<代码>[备选案文](C++11,2.1,C++03)中。

标准要求的细节各不相同:预处理分为几个阶段,因为它在标准的不同点都很重要,“已做”什么,在界定某种行为范围时,什么是“需要做的”。 因此,尽管它没有告诉你如何写法,但它给你一个非常明确的路线图。

而另一方面,联系则主要留给执行方决定如何实际实现,因为标准只注意how<>>。 a 仅指某一名字。

它没有详细说明教区的情况,只是说“由此引发的伤口是巧妙的,有的是 se的分析和翻译的”。 这是因为第3至15章全文需要填写这一细节。

它没有提到在教区/翻译阶段的内部代表,也没有提及优化阶段——这些代表对于汇编者的设计具有重要意义,但对于标准来说并不重要。 优化可在不同汇编者的不同地点进行。 长期以来,优化工作几乎完全处于汇编阶段,然后排出物体档案,联系人则担任职务。 我认为,现在严格的C++实施,至少可以在多个TU公司中做到某种优化。 因此,“他人”没有标准,实际上随着时间的推移而变化。

C++规格在许多方面是故意模糊的,大多是保持独立。 语言模糊的很多领域没有引起更多的关注,例如,你通常可以依靠8个轨道。 然而,其他问题,例如使用多重遗产的结构的布局问题,以及虚拟职能对班级的影响,都是一个真正的关切问题。 这些问题影响到与不同汇编者产生的编码的一致性。 C++的“应用双向接口”(或ABI)严格界定,因此,在出现问题时,有时不得不分解成C。 撰写原始界面是一个很好的例子。

同样,标准并没有详细说明如何建立汇编者,因为有许多重要决定和特征区分汇编者。 例如,MSVC可以进行部分建筑(允许使用和继续使用),海湾合作委员会就是这样做的。 不过,一般而言,所有汇编者都从事类似阶段的工作:预处理、yn、确定方案流程、编制一个编号表和编制一系列可随后加以执行的指令。 奥赫,把这些物体档案连接起来,通常是由联系人进行的。

我有一个简短的眼光,很难找到个别汇编者的描述。 我怀疑,仅仅出于商业原因,微软公司等商业编纂者在这方面做了大量发言。 海湾合作委员会是你的最佳信条,,但微软愿意介绍这一进程。 虽然如此,但是这只是粗略的禁制:汇编者的工作基本上相同。 真正的黄金是它们如何执行这些阶段、算法和所使用的数据结构。 在这方面,。 我推荐这本书。 几年后,我购买了一所大学课程的新品牌,我从图书馆借用了我的大部分教科书。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?