CC,gcc和g的区别++? [英] Difference between CC, gcc and g++?

查看:233
本文介绍了CC,gcc和g的区别++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是3编译器CC,海湾合作委员会之间的差异,G编译时++
C和C ++ code组装方面
code一代,可用的库,语言功能等。

What are the difference between the 3 compilers CC, gcc, g++ when compiling C and C++ code in terms of assembly code generation, available libraries, language features, etc.?

推荐答案

这个问题的答案是特定于平台的;发生什么事在Linux上是在Solaris上发生的事情,例如不同的。

The answer to this is platform-specific; what happens on Linux is different from what happens on Solaris, for example.

容易的部分(因为它不是特定于平台的)是海湾合作委员会和分离G ++:

The easy part (because it is not platform-specific) is the separation of 'gcc' and 'g++':


  • GCC是从GCC(GNU编译器集合)。GNU C编译器

  • 先按g ++是GNU C ++编译器从GCC。

最困难的部分,因为它是特定于平台的,是'CC'(与'CC')

The hard part, because it is platform-specific, is the meaning of 'CC' (and 'cc').


  • 在Solaris上,CC通常是Sun C ++编译器的名称。

  • 在Solaris上,CC通常Sun C编译器的名称。

  • 在Linux中,如果存在的话,CC可能是一个链接到G ++。

  • 在Linux上,CC是gcc的一个环节。

然而,即使是在Solaris上,这可能是因为CC是从的/ usr / UCB 旧的基于BSD的C编译器。在实践中,通常没有安装,只是有失败,那些谁试图编译和安装自配置软件肆虐的存根。

However, even on Solaris, it could be that cc is the old BSD-based C compiler from /usr/ucb. In practice, that usually isn't installed and there's just a stub that fails, wreaking havoc on those who try to compile and install self-configuring software.

在HP-UX,默认的'CC'仍然是一个K&安培;安装了R-只有C编译器,允许在必要时内核重新链接,并不能用于现代软件的工作,因为它不支持标准C.你有使用替代编译器的名称(ACCIIRC)。同样,在AIX上,系统C编译器的推移名称,如XLC或xlc32。

On HP-UX, the default 'cc' is still a K&R-only C compiler installed to permit relinking of the kernel when necessary, and unusable for modern software work because it doesn't support standard C. You have to use alternative compiler names ('acc' IIRC). Similarly, on AIX, the system C compiler goes by names such as 'xlc' or 'xlc32'.

经典,系统默认的编译器被称为CC和自我配置的软件回退到上名字的时候不知道用什么。

Classically, the default system compiler was called 'cc' and self-configuring software falls back on that name when it doesn't know what else to use.

POSIX试图通过要求程序C89(原),后来C99存在立法的解决这个途径;这些都与ISO / IEC 9899兼容的编译器:1989年和9899:1999 C标准。这是值得怀疑的POSIX成功了。

POSIX attempted to legislate its way around this by requiring the programs c89 (originally) and later c99 to exist; these are the compilers compatible with the ISO/IEC 9899:1989 and 9899:1999 C standards. It is doubtful that POSIX succeeded.


问题询问在功能和库方面的差异。如前,答案是平台特定的部分和通用部分

The question asks about the differences in terms of features and libraries. As before, the answer is platform specific in part, and generic in part.

大鸿沟是C编译器和C ++编译器之间。在C ++编译器将接受C ++程序,并不会编译任意C程序。 (虽然可以编写C中也由C ++理解的子集,许多C程序是无效的C ++程序)。同样,C编译器将接受C程序并拒绝大多数C ++程序(因为大多数C ++程序使用c不可构造)。

The big divide is between the C compilers and the C++ compilers. The C++ compilers will accept C++ programs and will not compile arbitrary C programs. (Although it is possible to write C in a subset that is also understood by C++, many C programs are not valid C++ programs). Similarly, the C compilers will accept C programs and will reject most C++ programs (because most C++ programs use constructs not available in C).

一组可用库取决于语言。 C ++程序通常可以使用C库给定的平台上; C程序通常不能使用C ++库。因此,C ++提供了一个更大的库。

The set of libraries available for use depends on the language. C++ programs can usually use C libraries on a given platform; C programs cannot usually use C++ libraries. So, C++ has a larger set of libraries available.

请注意,如果你是在Solaris上,由CC产生的目标code是不是用g生产++对象code兼容 - 他们是与事物不同的公约,如异常处理和两个独立的编译器名称重整(和名称重整是故意的不同,以确保不兼容的对象文件没有连接在一起!)。这意味着,如果你想使用与CC编译一个库,必须编译与CC整个程序。这也意味着,如果你想使用一个库编译CC和另一个与G ++编译,你的运气了。你必须重新编译至少图书馆之一。

Note that if you are on Solaris, the object code produced by CC is not compatible with the object code produced by g++ -- they are two separate compilers with separate conventions for things such as exception handling and name mangling (and the name mangling is deliberately different to ensure that incompatible object files are not linked together!). This means that if you want to use a library compiled with CC, you must compile your whole program with CC. It also means that if you want to use one library compiled with CC and another compiled with g++, you are out of luck. You have to recompile one of the libraries at least.

在生成的汇编的质量方面,GCC(GNU编译器集合)做了很好的工作。但有时本地编译器的工作好一点。英特尔编译器有一个尚未在GCC复制更广泛的优化,我相信。但是,任何这样的pontifications是危险的,而我们不知道你关心什么平台做的。

In terms of quality of assembler generated, the GCC (GNU Compiler Collection) does a very good job. But sometimes the native compilers work a bit better. The Intel compilers have more extensive optimizations that have not yet been replicated in GCC, I believe. But any such pontifications are hazardous while we do not know what platform you are concerned with.

在语言功能方面,编译器都普遍槎相当接近现行标准(C ++ 98,C ++ 2003,C99),但通常的标准语言和语言的支持之间的微小差异编译器。旧的C89标准的支持实际上是为所有的C编译器相同(完整)。有在该语言的较暗角差异。你需要了解不确定的行为,系统定义的行为和未指定的行为;如果您未定义行为,你会得到在不同的时间不同的结果。也有许多选项(尤其是与海合会)来调整编译器的行为。海湾合作委员会有各种的扩展,让生活更简单,如果你知道你是唯一的目标定位是编译器的家庭。

In terms of language features, the compilers all generally hew fairly close to the current standards (C++98, C++2003, C99), but there are usually small differences between the standard language and the language supported by the compiler. The older C89 standard support is essentially the same (and complete) for all C compilers. There are differences in the darker corners of the language. You need to understand 'undefined behaviour', 'system defined behaviour' and 'unspecified behaviour'; if you invoke undefined behaviour, you will get different results at different times. There are also many options (especially with the GCC) to tweak the behaviour of the compiler. The GCC has a variety of extensions that make life simpler if you know you are only targetting that compiler family.

这篇关于CC,gcc和g的区别++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆