user1424739
user1424739

Reputation: 13755

What is the difference between c++ and g++ on Mac OS X (CommandLineTools)?

I see that c++ and g++ are mostly the same. Can they be used interchangably? When they will be different?

$ c++ --version
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ which c++
/Library/Developer/CommandLineTools/usr/bin/c++
$ which g++
/Library/Developer/CommandLineTools/usr/bin/g++

Upvotes: 0

Views: 2834

Answers (1)

pooya13
pooya13

Reputation: 2709

On MacOS, c++ is a symbolic link to the clang++ binary. In your case both c++ and g++ are the same Clang compiler for C++ (i.e. the LLVM compiler is being masqueraded as the GNU g++ compiler).

If you HAD installed the GCC compiler for C++ (more commonly known as g++), the differences between c++ and g++ would have been the differences between clang and gcc compilers. For example see this question or this compiler support table.

Upvotes: 1

Related Questions