Paul Solt
clang++ is awesome, goodbye g++
I finally got around to reading up on the clang compiler and I love it. The error messages are so helpful. Here’s a quick example with a syntax error. Lets compile it on the command line.
#include <iostream>
int main() {
std::cotut << "Hello World";
return 0;
}
What happens when I run the code with g++?
paulsolt@~/dev $ g++ test.cpp test.cpp: In function ‘int main()’: test.cpp:3: error: ‘cotut’ is not a member of ‘std’
Here’s what happens in clang++, notice how it highlights the position and it’s actually more helpful in fixing the error.
paulsolt@~/dev $ clang++ test.cpp
test.cpp:4:7: error: no member named 'cotut' in namespace 'std'; did you mean 'cout'?
std::cotut << "Hello World";
~~~~~^~~~~
cout
/usr/include/c++/4.2.1/iostream:63:18: note: 'cout' declared here
extern ostream cout; ///< Linked to standard output
2 Responses to clang++ is awesome, goodbye g++
Leave a Reply Cancel reply
Artwork Evolution
Facebook
@PaulSolt
- RT @collindonnell: Wrote a build script to update CFBundleVersion during App Store and ad hoc builds + commit & tag it in Git: http://t. ... 2012/02/20
- RT @vkhosla: Paul Graham: How to Start a Startup http://t.co/V5rX4oXD ; love it every time I read it other than focus on making money i ... 2012/02/20
- Climbing rocks (@ Eastern Mountain Sports w/ 3 others) [pic]: http://t.co/tDAW18Xt 2012/02/18
Github
Tags
animation App Store Artwork Evolution Boost Boot Camp C++ cross platform default values development Dual Monitors function pointers Gears of War 2 git GLUT graphics ImagineRIT Impulse inheritance iOS iPad iPhone Macbook Pro Mac OS X MacPorts member functions Objective-C OpenGL PAX 10 player/stage polymorphism programming remote control RIT Robot robotics SCM static methods STL svn 1.6 version control Windows XP Xbox 360 Xcode xcode 3.1.2 XNA







Looks good! How do we install clang++?
It’s in the upcoming editor from Apple. See the open source site: http://clang.llvm.org/