2.1.1 Visual C++(www.cppentry.com)不是唯一的C++(www.cppentry.com)编译器
C++(www.cppentry.com)作为一门高级语言,其源程序要得以执行必须要通过编译(compile),即将其转换成机器语言目标程序。用来编译C++(www.cppentry.com)源程序的编译器,即C++(www.cppentry.com)编译器(compiler)。有意思的是,C++(www.cppentry.com)的编译器种类也是非常之多。但由于C++(www.cppentry.com)语言过于复杂,以及它经历了较长时间的演变,直到现在也只有少数几个编译器完全符合C++(www.cppentry.com)标准。以下列出了一些常见的C++(www.cppentry.com)编译器。
1.Visual C++(www.cppentry.com)
Visual C++(www.cppentry.com)正是Microsoft Visual Studio和Microsoft Visual Studio.NET 200X(包括2003、2005、2008等)中所带的C++(www.cppentry.com)编译器,它由Microsoft公司研制。在Visual C++(www.cppentry.com) 6.0中,因为编译器有太多地方不能与后来出现的C++(www.cppentry.com)标准相吻合而饱受批评。Visual C++(www.cppentry.com) 6.0对标准化C++(www.cppentry.com)的兼容只有70%(有的数字表示其兼容性更低)。但是随着C++(www.cppentry.com)编译器设计大师Stanley Lippman及诸多C++(www.cppentry.com)社群牛人的加盟,在Visual Studio.NET 2003中,Visual C++(www.cppentry.com)编译器已经成为一个非常成熟可靠的C++(www.cppentry.com)编译器了。Dr.Dobb's Journal的评测显示Visual C++(www.cppentry.com) 7.1对标准C++(www.cppentry.com)的兼容性高达98.22%。
2.Borland C++(www.cppentry.com)
这是Borland C++(www.cppentry.com) Builder和Borland C++(www.cppentry.com) Builder X这两种开发环境的后台编译器。Borland C++(www.cppentry.com)由老牌开发工具厂商Borland倾力打造。该公司的编译器素来以速度快、空间效率高著称,Borland C++(www.cppentry.com)系列编译器秉承了这个传统,属于非常优质的编译器。标准化方面早在5.5版本的编译器中对标准化C++(www.cppentry.com)的兼容就达到了92.73%。目前最新版本是Borland C++(www.cppentry.com) Builder X中的6.0版本,官方称100%符合ANSI/ISO的C++(www.cppentry.com)标准及C99标准。
3.GNU C++(www.cppentry.com)
GNU C++(www.cppentry.com)是著名的开源C++(www.cppentry.com)编译器,是类UNIX操作系统下编写C++(www.cppentry.com)程序的首选。其特点是有非常好的移植性,你可以在非常广泛的平台上使用它,同时也是编写跨平台嵌入式程序很好的选择。另外在符合标准这个方面GCC一直都非常好,GCC 3.3大概能够达到96.15%。但是由于其跨平台的特性,在代码尺寸速度等优化上略差一点。
4.Intel C++(www.cppentry.com)
Intel C++(www.cppentry.com)为著名CPU制造厂商Intel出品的编译器,其对于Intel x86结构的CPU经过特别的优化。在某些应用情况下,特别是数值计算等高性能应用,仅仅采用Intel的编译器编译就能大幅度地提高性能。
如上这种关系采用UML类图来表示的话,就是图2-1。其中Visual C++(www.cppentry.com) 6.0被单独提出来,是因为它很短小精悍,一直颇受Visual C++(www.cppentry.com)程序员的喜爱。

比如,如下是一段符合标准C++(www.cppentry.com)语法的程序:
但是它在Visual C++(www.cppentry.com) 6.0上就无法通过。反之,在Visual C++(www.cppentry.com) 6.0中通过的程序,在其他标准C++(www.cppentry.com)的编译器中也有可能无法通过。更严重的问题体现在Visual C++(www.cppentry.com) 6.0对模板、STL的支持上,那种后果基本上是一塌糊涂。但是,相对于其后继版本Visual Studio.NET的庞大身躯,Visual C++(www.cppentry.com) 6.0可谓是Microsoft公司的经典之作,很多应用程序仍然在使用着Visual C++(www.cppentry.com) 6.0。
【责任编辑:
王晶 TEL:(010)68476606】