JavaRunner JavaRunner - 2 months ago 21
C++ Question

Where can I find a version of current using GCC compiler on Mac?

I use a command:

g++ -v
to know what's the version of GCC currently using. But I get following output:

$ g++ -v
Configured with: --prefix=/Applications/ --with-gxx-include-dir=/Applications/
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
InstalledDir: /Applications/

So I don't understand. Am I using LLVM or GCC when I compile my program with:
g++ test.cpp
? Why do I see the information about LLVM when I'm requesting the information about GCC? LLVM used with Clang as a frontend.
What have I missed there?


The short answer is you are using Apple's LLVM pretending to be gcc/g++. This is not a huge problem. One place where I was annoyed enough was the fact that gcc's -march=native optimizations just do not work with LLVM which resulted in about 50% worse performance in a rather CPU-intensive program I was running.

Getting a full gcc based toolchain installed involves a lot of work. See Compiling GCC 6 on macOS Sierra and Compiling GCC 6 on OS X.

If you get the real thing working, you might also want to build dedicated GNU binutils etc.