clang vs gcc : 代码出错提示功能对比
来源:互联网 发布:数据库全书 编辑:程序博客网 时间:2024/05/18 01:05
今天研究c++ const 的问题,顺便做了一下gcc 与 clang 的代码编译错误提示对比,结论是,clang这个晚辈确实比gcc人性化多了。
参考:
http://www.cnblogs.com/Fancyboy2004/archive/2008/12/23/1360810.html
以下是测试代码:
- #include <cstdlib>
- class Apple
- {
- public:
- Apple (){}; /* constructor */
- int GetCount() /* 非const 成员函数 */
- {
- return m_iData;
- };
- protected:
- int m_iData;
- }; /* ----- end of class Apple ----- */
- using namespace std;
- int main ( int argc, char *argv[] )
- {
- const Apple apple;
- apple.GetCount(); /* 错误 */
- return EXIT_SUCCESS;
- } // ---------- end of function main ----------
- //save to a.cc
gcc编译命令:
- $ g++ a.cc
- a.cc: In function ‘int main(int, char**)’:
- a.cc:22: error: passing ‘const Apple’ as ‘this’ argument of ‘int Apple::GetCount()’ discards qualifiers
clang:
- $ clang++ a.cc
- a.cc:22:5: error: member function 'GetCount' not viable: 'this' argument has
- type 'const Apple', but function is not marked const
- apple.GetCount(); /* 错误 */
- ^~~~~
- a.cc:8:13: note: 'GetCount' declared here
- int GetCount() /* 非const 成员函数 */
- ^
0 0
- clang vs gcc : 代码出错提示功能对比
- GCC,LLVM,Clang编译器对比
- GCC,LLVM,Clang编译器对比
- GCC,LLVM,Clang编译器对比
- GCC,LLVM,Clang编译器对比
- vs引用错误不提示代码出错
- 编译器三:GCC,LLVM,Clang编译器对比
- [Mac]GCC,LLVM,Clang编译器对比
- gcc警告提示功能
- 简单设置MyEclipse与VS一样的代码提示功能
- 简单设置MyEclipse与VS一样的代码提示功能
- 用GCC或者Clang观察预处理后的C++代码
- VS代码提示快捷键
- VS代码提示快捷键
- FFMpeg编码提示gcc出错问题
- Linux下clang/gcc使用pthread.h编译出错undefined reference to `pthread_create'
- clang-format中文出错
- clang、gcc、LLVM
- 项目管理的十大原则
- 情报搜集阶段
- 数据公钥加密和认证中的私钥公钥
- Mongodb2.6升级修改以及新特性
- MFC 文件操作
- clang vs gcc : 代码出错提示功能对比
- 【并查集】HDU 1325 Is It A Tree?
- UITextView 退出键盘的方式
- linux input设备驱动
- linux 入门 初学者安装
- Cocos2d-x v3.x官方文档]动作 (Action)
- CharIndex的用法
- java classloader讲解一
- DWR中函数测试