GCC/gcc/g++/CC/cc区别

  平常在Linux上经常会用到gcc或者g++来编译程序,但对这两者的理解也就停留在一个是用来编译C程序,另一个是用来编译C++程序的(请注意:这种说法是有问题的,待会改进)

  1. GCC

  GCC,是GNU Compiler Collection的缩写,表示的是GNU编译器套装,包含了gcc、g++。

  gcc,是GNU C Compiler的缩写,包含于GCC。

  g++,是GNU C++ Compiler的缩写,包含于GCC。

  2. CC

  CC是UNIX Compiler Command缩写。对于CC,则是跟具体平台相关的。根据stackoverflow的一个回答,摘录如下:

  • On Solaris, CC is normally the name of the Sun C++ compiler
  • On Solaris, cc is normally the name of the Sun C compiler
  • On Linux, if it exists, CC is probably a link to g++.
  • On Linux, cc is a link to gcc.

  3. 区别与联系

   3.1 对于gcc和g++区别,根据在CentOS 7上的实验证明

  1)gcc和g++均能够编译并链接C语言程序;

  2)对于仅包含C语言特性但文件后缀是cpp的程序,gcc是能够编译并链接的,但对于包含了C++语言特性的程序,gcc是无能为力的。这时就需要用到g++了。

   3.2 对于CC在Linux上,根据在CentOS 7上的实验证明

  1)cc确实是指向gcc的。输入命令ls -l /usr/bin/cc能得到“/usr/bin/cc->gcc”的结果。

  2)CC并不存在,而是常用于Makefile文件中,作为对g++的指代,如CC=g++

  更多资料:

  Difference between CC, gcc and g++?

  Difference between GCC and CC Compiler

原文地址:https://www.cnblogs.com/xiehongfeng100/p/4370016.html