gcc和g++的区别
参考What is the difference between g++ and gcc?
1.The actual compiler is "cc1" for C and "cc1plus" for C++; both gcc and g++ are drivers (which call the preprocessor/compiler/assembler/linker as needed).
2.For c++ you should use g++.
It's the same compiler (e.g. the GNU compiler collection). GCC or G++ just choose a different front-end with different default options.
In a nutshell: if you use g++ the frontend will tell the linker that you may want to link with the C++ standard libraries. The gcc frontend won't do that (also it could link with them if you pass the right command line options).
3.You can link the std C++ library in gcc by passing -lstdc++ parameter.
4.GCC: GNU Compiler Collection
- Referrers to all the different languages that are supported by the GNU compiler.
gcc: GNU C Compiler
g++: GNU C++ Compiler
The main differences:
- gcc will compile: *.c/*.cpp files as C and C++ respectively.
- g++ will compile: *.c/*.cpp files but they will all be treated as C++ files.
- Also if you use g++ to link the object files it automatically links in the std C++ libraries (gcc does not do this).
- gcc compiling C files has less predefined macros.
- gcc compiling *.cpp and g++ compiling *.c/*.cpp files has a few extra macros.
Extra Macros when compiling *.cpp files:
#define __GXX_WEAK__ 1
#define __cplusplus 1
#define __DEPRECATED 1
#define __GNUG__ 4
#define __EXCEPTIONS 1
#define __private_extern__ extern
综上所述:
1.gcc和g++只是一个前端,真正执行编译的是c语言对应的"cc1"和c++对应的"cc1plus"。
2.gcc可以编译、链接c和c++,通过后缀名.c和.cpp来区分。但链接时必须添加-lstdc++参数才能保证c++的正确链接,c语言不用。
3.g++用来编译、链接c++,无论后缀是.c或.cpp,都会当做c++来处理。因为是专为c++做的编译工具,所以编译c++一般用g++。
4.gcc和g++在编译c++时会额外添加几个宏,如上第四点提到的。
gcc和g++的区别的更多相关文章
- Linux - gcc和g++的区别
一般linux系统都自带了gcc编译器的,你可以用你的安装光盘去安装,如果你是觉得自带的gcc版本太低了,可以去gcc的官方网站可以下载到,编译需要很长的时间,如果你只编译C或者C++可以只下载gcc ...
- 【转载】gcc和g++的区别
[说明]本文转载自 静心 的文章 http://blog.163.com/lu_jun520/blog/static/5699613420116205148239/ 一般linux系统都自带了gcc编 ...
- gcc和g++的区别【转自中国源码网】
gcc和g++的区别[转自中国源码网] gcc和g++都是GNU(组织)的一个编译器. 误区一:gcc只能编译c代码,g++只能编译c++代码两者都可以,但是请注意:1.后缀为.c的,gcc把它当作是 ...
- linux中gcc和g++的区别
1.两者都是编译器 2.gcc编译c语言:g++既可以编译c语言,也可以编译c++语言 3.gcc不能自动链接库文件,一般用g++来链接库文件,非要用gcc的话,一般使用gcc -lstdc++命令 ...
- gcc 与 g++的区别
原文: http://www.cnblogs.com/wb118115/p/5969775.html ------------------------------------------------- ...
- 【C/C++】Linux的gcc和g++的区别
Windows中我们常用vs来编译编写好的C和C++代码:vs把编辑器,编译器和调试器等工具都集成在这一款工具中,在Linux下我们能用什么工具来编译所编写好的代码呢,其实Linux下这样的工具有很多 ...
- 结合python版本安装python-devel gcc和g++的区别 安装前做yum搜索
[test@ecs autocloudservices]# yum install python-develLoaded plugins: fastestmirrorLoading mirror sp ...
- gcc 与g++的区别
原文 http://www.cnblogs.com/wb118115/p/5969775.html 什么是gcc / g++ 首先说明:gcc 和 GCC 是两个不同的东西 GCC:GNU Compi ...
- gcc和g++的区别:安装、版本、编译(转)
用以下命令: yum install gcc 安装的只有gcc,而不会安装g++.gcc是编译器合集,而gcc-g++或简称g++则是C++编译器.gcc成为了编译器的选择器.gcc通过识别被编译的源 ...
- gcc与g++的区别
一:gcc与g++比较 编译c/c++代码的时候,有人用gcc,有人用g++,于是各种说法都来了,譬如c代码用gcc,而 c++代码用g++,或者说编译用gcc,链接用g++,一时也不知哪个说法正确, ...
随机推荐
- 使用jvisualvm和飞行记录器分析Java程序cpu占用率过高
一.jvisualvm使用 JDK1.6中Oracle提供了一个新的JVM监控工具:jvisualvm.下面重点介绍如何在本地通过远程的方式打开Linux服务器上的jvisualvm. 1.Xmana ...
- symonfy 项目根目录下没有 bin/console 文件的解决方法
“Could not open input file: bin/console” Error comes when try to Run the Symfony Application 在采纳的答案中 ...
- orale做报表常用函数和表达式的总结
最近一段时间连续的做了几十张报表,通过原生sql对数据进行分析 ,也算是有了一定的了解,发现其中一些函数和表达式使用频率较高,现总结如下: (1).round()函数 round函数说白了就是把一 ...
- arguments 函数内部属性
1.arguments 是在function方法里面的,是实参数组,用法是挺多的,下面来记录一下 2.利用arguments实现方法的重载 //01.使用argument模拟方法重载 function ...
- 【HTTPS】Https和SSL学习笔记(二)
此文讲述证书的相关信息,参考文章链接http://www.guokr.com/post/116169/ 一. 证书的类型 常用的几种证书如下: (1) SSL证书,用于加密HTTP (2) 代码签名证 ...
- 经历:Java中字符串中按照多个字符拆分或替换:split()和replaceAll()
一.replaceAll() 今天,遇到了这样的一个字符串[如下代码]: String s="@0|新港@0|天津@0|东莞@0|南沙@0|营口@0|钦州@0|上海@0|汕头@0|连云港@0 ...
- Mysql 的函数
函数 MySQL函数分为系统函数与自定义函数 系统函数: pow(m,n) 求m的n次方 rand() 随机获取0至1之间的小数 floor(); ...
- 第28条:利用有限制通配符来提升API的灵活性
参数化类型是不可变的.对两个不同类型T1和T2而言,List<T1>与List<T2>没有父子类型关系. 考虑: public class Stack<E> { p ...
- Windows Phone中用到的类名及对应的命名控件及引用
//INotifyPropertyChanged using System.ComponentModel; //ICommand using System.Windows.Input; //Actio ...
- Linux C 程序 输入输出函数(THREE)
标准输入输出函数#include<stdio.h>stdio 是 standard input & output 的缩写 字符数据输入输出函数: putchar() , getch ...