So, I was doing some doing some research for a program I'm working on and I stumbled upon the information that clang++ is a better alternative to g++ on Mac. I've been trying to use it because I can define that I want to use C++11, yet, the file output is a.out. Is there any way I can fix this or am I stuck with renaming it?

Recommended Answers

All 3 Replies

If it's anything like gcc then -o myfile in the makefile link statement should do it.

Yes, as AD says, you have to specify the output name with the -o option. Clang uses all the same options as GCC, as much as possible. So, if you need instructions on using clang and you can't find what you need, just look for instructions on using GCC, they usually apply to clang as well. Clang is meant to be a drop-in replacement for GCC. This is because most build systems (makefiles, cmake, etc..) are mainly geared towards dealing with GCC and ICC, which use the same main options and behaviors, and they're the two main compiler suites used for professional development, and so, it makes sense for clang to follow that de facto standard.

I stumbled upon the information that clang++ is a better alternative to g++ on Mac.

Yes, indeed. LLVM/Clang is the official C++ / C / Objective-C compiler for Mac. It's often difficult to get good up-to-date versions of GCC to work on Mac, due to Apple not allowing it in mainstream software repositories (you have to compile it from source or get it from third-party sources). Not to mention that clang is a better compiler than GCC, whichever the operating system you use.

If it's anything like gcc then -o myfile in the makefile link statement should do it.

I honestly never thought it would be the same as gcc. Wow, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.