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
- No public Twitter messages.
Github
Tags
Apple application testing App Store Artwork Evolution Boost bundle C++ cross platform development Dual Monitors Facebook Gears of War 2 gestures git GLUT iOS iPad iPhone iphone dev iphone dev 101 logic testing Mac Macbook Pro mac osx Mac OS X NSDocument Objective-C OCUnit OpenGL player/stage presentation remote control resource paths RIT SCM skillshare slides tdd testable code testing unit testing Windows XP Xbox 360 Xcode xcode 4







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