Reputation: 2555
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/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
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?
Upvotes: 1
Views: 3630
Reputation: 118166
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.
Upvotes: 3
Reputation: 1407
You're using LLVM. Unless you've specifically installed GCC (e.g. with Homebrew) you don't have GCC installed. References to GCC on your system are aliases to Clang intended to allow most code to compile without problems.
Upvotes: 3