clang和gcc的对比,来看看哪个更具有优势!
2014-06-16 17:39
190 查看
测试平台:ubuntu 12.04.4 64bit
硬件都是一样的哈!
首先安装:gcc(也许系统自带,也许没有,暂时不管)
然后再安装clang
用vim编辑测试代码:
(推荐一篇vim+completeme的配置文章,猛击这里:)
(肯定是有问题的哈)
首先是clang
hello.c:5:5: error: use of undeclared identifier 'hell'; did you mean 'hello'?
if(hell==12)
^~~~
hello
hello.c:4:6: note: 'hello' declared here
int hello=12;
^
hello.c:9:10: error: use of undeclared identifier 'hel'
else if(hel==12)
^
hello.c:11:25: error: expected ';' after expression
printf("hello world!")
^
;
3 errors generated.
然后是gcc的
hello.c: 在函数‘main’中:
hello.c:5:5: 错误: ‘hell’未声明(在此函数内第一次使用)
hello.c:5:5: 附注: 每个未声明的标识符在其出现的函数内只报告一次
hello.c:9:10: 错误: ‘hel’未声明(在此函数内第一次使用)
hello.c:12:2: 错误: expected ‘;’ before ‘}’ token
可以看出clang的报错精确程度确实比gcc高些
所以;life is short ,use clang
硬件都是一样的哈!
首先安装:gcc(也许系统自带,也许没有,暂时不管)
sudo apt-get install build_essential
然后再安装clang
sudo apt-get install clang-3.3 clang-3.3-doc
用vim编辑测试代码:
(推荐一篇vim+completeme的配置文章,猛击这里:)
(肯定是有问题的哈)
#include<stdio.h> int main() { int hello=12; if(hell==12) {
printf("hello is %d",hello); } else if(hel==12) { printf("hello world!") } return 0; }來看看两个报错情况:
首先是clang
hello.c:5:5: error: use of undeclared identifier 'hell'; did you mean 'hello'?
if(hell==12)
^~~~
hello
hello.c:4:6: note: 'hello' declared here
int hello=12;
^
hello.c:9:10: error: use of undeclared identifier 'hel'
else if(hel==12)
^
hello.c:11:25: error: expected ';' after expression
printf("hello world!")
^
;
3 errors generated.
然后是gcc的
hello.c: 在函数‘main’中:
hello.c:5:5: 错误: ‘hell’未声明(在此函数内第一次使用)
hello.c:5:5: 附注: 每个未声明的标识符在其出现的函数内只报告一次
hello.c:9:10: 错误: ‘hel’未声明(在此函数内第一次使用)
hello.c:12:2: 错误: expected ‘;’ before ‘}’ token
可以看出clang的报错精确程度确实比gcc高些
所以;life is short ,use clang
相关文章推荐
- GCC,LLVM,Clang编译器对比
- 编译器三:GCC,LLVM,Clang编译器对比
- 对比传统关系型数据库,NoSQL有着非常显著的性能和扩展性优势,然而这些优点却建立在一些关键功能的丢失之上,比如事务、join等。那么在数据体积激增的当下,究竟哪个数据库才会适合你的场景
- GCC,LLVM,Clang编译器对比
- 腾讯云和阿里云对比哪个好?云计算优势测评
- GCC,LLVM,Clang编译器对比
- 对比看看两个方法效果哪个好
- GCC,LLVM,Clang编译器对比
- [Mac]GCC,LLVM,Clang编译器对比
- clang vs gcc : 代码出错提示功能对比
- GCC,LLVM,Clang编译器对比
- 转:GCC,LLVM,Clang编译器对比
- GCC,LLVM,Clang编译器对比
- 用GCC或者Clang观察预处理后的C++代码
- H5开发具有哪些优势?
- 用clang编译SPEC2006 过程中的问题(与gcc,ld相关)
- 八大机器学习框架对比及Tensorflow的优势
- 【分享】说说标准——层叠顺序(Cascading order),看看到底哪个样式在起作用?
- 请教:如何知道当前所用的gcc调用的是哪个版本的glibc库?及这个glibc库的位置?谢谢!
- premake 使用clang替换gcc