Browsed by
标签: bootstrapping

GCC 用 C++ 来编译

GCC 用 C++ 来编译

GCC在2012年8月15日的时候,merge了一个patch – Merge from cxx-conversion branch,这意味着,以后在GCC的编译只能用C++的编译器了,也意味着,gcc的实现代码开始转向C++了。

你可能会有两个问题,

  • 一个问题是为什么GCC要转成C++的实现?
  • 没有C++的编译器,我怎么编译C++编译器的代码?这不是“鸡生蛋还是蛋生鸡”的问题么?

那,我们来看一看吧。

为什么要用C++

GNU的C++ Conversion文档中,我们可以在Background中看到这样的描述:

Whether we use C or C++, we need to try to ensure that interfaces are easy to understand, that the code is reasonably modular, that the internal documentation corresponds to the code, that it is possible for new developers to write new passes and to fix bugs. Those are the important issues for us to consider. The C++ features which are not present in C — features which are well documented in many books and many web sites — are not an important issue.

这句话的意思可以理解为,今天GCC在用C语言的实现已经有点hold不住了,因为,开发人员觉得,不管我们用C或C++,都需要努力确保接口是容易理解的,这样我们的代码是想当理性地被模块化的,这样内部文档和代码一致,这样可以更好地组织代码,这样有利于新人了fix-bug。而C++正好可以让他们更好的完成这些东西。

GNU还给出了下面这些理由:

阅读全文 Read More

好烂啊有点差凑合看看还不错很精彩 (22 人打了分,平均分: 3.59 )
Loading...