博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
clang和gcc的对比,来看看哪个更具有优势!
阅读量:4302 次
发布时间:2019-05-27

本文共 1009 字,大约阅读时间需要 3 分钟。

测试平台:ubuntu 12.04.4 64bit

硬件都是一样的哈!

首先安装:gcc(也许系统自带,也许没有,暂时不管)

sudo apt-get install build_essential

然后再安装clang

sudo apt-get install clang-3.3 clang-3.3-doc
用vim编辑测试代码:

(推荐一篇vim+completeme的配置文章,猛击这里:)

(肯定是有问题的哈)

#include
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

转载地址:http://gnows.baihongyu.com/

你可能感兴趣的文章
永久修改PATH环境变量的几种办法
查看>>
大数据学习之HDP SANDBOX开始学习
查看>>
Hive Beeline使用
查看>>
Centos6安装图形界面(hdp不需要,hdp直接从github上下载数据即可)
查看>>
CentOS7 中把yum源更换成163源
查看>>
关于yum Error: Cannot retrieve repository metadata (repomd.xml) for repository:xxxxxx.
查看>>
linux下载github中的文件
查看>>
HDP Sandbox里面git clone不了数据(HTTP request failed)【目前还没解决,所以hive的练习先暂时搁置了】
查看>>
动态分区最佳实践(一定要注意实践场景)
查看>>
HIVE—索引、分区和分桶的区别
查看>>
Hive进阶总结(听课总结)
查看>>
大数据领域两大最主流集群管理工具Ambari和Cloudera Manger
查看>>
Sqoop往Hive导入数据实战
查看>>
Mysql到HBase的迁移
查看>>
Sqoop import进阶
查看>>
Hive语句是如何转化成MapReduce任务的
查看>>
Hive创建table报错:Permission denied: user=lenovo, access=WRITE, inode="":suh:supergroup:rwxr-xr-x
查看>>
Hive执行job时return code 2排查
查看>>
hive常用函数及数据结构介绍
查看>>
Hive面试题干货(亲自跟着做了好几遍,会了的话对面试大有好处)
查看>>