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还给出了下面这些理

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值