Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ 14 compiler for OS X [closed]

Tags:

c++

macos

can someone recommend a compiler that supports c++ 14 on the OS X platform? I'm studying programming and principles by Bjarne Stroustrup and need some assistance with acquiring the appropriate compiler for the context of the book (c++ 14).

like image 563
dcrearer Avatar asked Aug 28 '14 15:08

dcrearer


People also ask

Does Mac have a C++ compiler?

Clang is a compiler created by Apple written over the LLVM compiler. It can be used to compile C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript. Command-line developer tools install clang. Once command-line tools are installed, clang --version can be used to check if clang is installed.

Can you run C code on Mac?

To run the C program in MacOS we need a code editor and code compiler. The Code editor is used to write source code while the code compiler converts the source code into executable files. To write the source code Microsoft Visual Studio Code is used while to convert it into executable files we use command-line tools.

Is gcc compiler available for Mac?

Done, the gcc version 4.2. 1 is installed on Mac OS X successfully.

How do I find gcc OSX?

You can run brew info gcc to get path where it is installed and get exact name of the binary by listing the directory. $ brew info gcc gcc: stable 11.2. 0 (bottled), HEAD GNU compiler collection https://gcc.gnu.org/ /usr/local/Cellar/gcc/11.2.


3 Answers

The best compiler for use on OS X is clang. C++14 is fully supported in clang as of 3.4: http://clang.llvm.org/cxx_status.html.

The current Xcode 6 betas come with a 3.4 based clang so you can just use that.

(Source: I am a compiler engineer working at Apple)

like image 158
Beanz Avatar answered Oct 30 '22 00:10

Beanz


You should install Macports and then you have a choice of GCC 4.8 or 4.9 and Clang 3.5 or 3.6 by simply typing:

$ sudo port install clang-36

or

$ sudo port install gcc49

Note: you'll want to have Xcode installed first.

like image 38
trojanfoe Avatar answered Oct 30 '22 00:10

trojanfoe


The standard compiler provided by apple is Clang. Here it claims it is c++14 aware:

http://clang.llvm.org/cxx_status.html#cxx14

To get it available I think the easiest way is to install Xcode.

like image 42
Emanuele Paolini Avatar answered Oct 29 '22 23:10

Emanuele Paolini