【问题标题】:What is the difference between c++ and g++ on Mac OS X (CommandLineTools)?Mac OS X(CommandLineTools)上的c ++和g ++有什么区别?
【发布时间】:2019-06-08 23:05:42
【问题描述】:

我看到 c++ 和 g++ 基本相同。它们可以互换使用吗?他们什么时候会不同?

$ 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++

【问题讨论】:

    标签: c++ xcode macos g++ xcode-command-line-tools


    【解决方案1】:

    在 MacOS 上,c++ 是指向 clang++ 二进制文件的符号链接。在您的情况下,c++g++ 都是 C++ 的相同 Clang 编译器(即 LLVM 编译器被伪装成 GNU g++ 编译器)。

    如果您已经为 C++(通常称为 g++)安装了 GCC 编译器,那么 c++ 和 g++ 之间的差异将是 clang 和 gcc 编译器之间的差异。例如查看this questionthis compiler support table

    【讨论】:

    • 为什么用--version 调用它们会得到不同的结果(第一行)?谢谢。
    • 好问题!我不知道:)
    猜你喜欢
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    相关资源
    最近更新 更多