0

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++
user1424739
  • 11,937
  • 17
  • 63
  • 152

1 Answers1

1

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.

pooya13
  • 2,060
  • 2
  • 23
  • 29