Tommy Herren
Tommy Herren

Reputation: 31

Is the LLVM 5.0 compiler equivalent to the GCC compiler?

I have to write my projects for class in ISO C++ or C++/CLI and while the professor explains how to accomplish this in Windows, it is very difficult to know how to setup the equivalent on my Mac. I am currently running xCode 5.0.2 and it seems to compile the sample applications with no problem using the LLVM 5.0 compiler. I've read that Apple no longer supports GCC compiler, so my question is are the two compilers equivalent? Will code that runs in GCC compiler also work in the LLVM 5.0 compiler?

Upvotes: 2

Views: 249

Answers (3)

Magnus Reftel
Magnus Reftel

Reputation: 1009

Mostly. Being compatible with GCC is one of Clang's primary goals (see http://clang.llvm.org/features.html#gcccompat ). That said, you can install gcc via MacPorts, http://www.macports.org/ if you really need it.

Upvotes: 0

Sebastian Redl
Sebastian Redl

Reputation: 71889

There is no LLVM 5.0. The LLVM project is currently at version 3.4. The Apple LLVM/Clang variant shipped with XCode 5 may carry a version number that corresponds to the XCode version, but that is mildly misleading.

That said, yes, most stuff that works with GCC 4.2 (the last one that Apple shipped) will work just fine with LLVM/Clang.

C++/CLI, on the other hand, is a Microsoft-proprietary thing and you will not be able to use it on a Mac no matter what, and neither GCC nor Clang support it.

Upvotes: 6

John Dibling
John Dibling

Reputation: 101446

Will code that runs in GCC compiler also work in the LLVM 5.0 compiler?

If by "runs" you mean "compiles," then yes, assuming your code is Standard-compliant.

Weather or not your code is Standard-complliant depends, in part, on how well your professor is doing his job.

Upvotes: 0

Related Questions