C语言 如何在mac上找到gcc版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20410587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 10:27:19  来源:igfitidea点击:

how to find gcc version on mac

cmacosgcc

提问by subhash kumar singh

I am using OS 10.9 on mac machine. I want to know the version of gcc I am using. So I tried gcc --versionon terminal and it results :

我在 mac 机器上使用 OS 10.9。我想知道我正在使用的 gcc 版本。所以我gcc --version在终端上试了一下,结果是:

$ gcc --version
Configured with: --prefix=/Applications/Xcode5-DP.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode5-DP.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.1.58) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

Here in output, there is no detail related to gcc but clang is there. I am confused whether gcc command executes clang or gcc(gnu).

在输出中,没有与 gcc 相关的细节,但有 clang。我很困惑 gcc 命令是执行 clang 还是 gcc(gnu)。

采纳答案by danfuzz

You seem to notactually have gcc on your path. As of recent versions of Xcode, it installs a "gcc" that is instead a link to Clang.

你似乎并不实际拥有的路径上的gcc。从 Xcode 的最新版本开始,它安装了一个“gcc”,而不是一个指向 Clang 的链接。

回答by serghei

gcc -dumpversion | cut -f1 -d.

-dumpversionPrint the compiler version (for example, 3.0) — and don't do anything else.

-dumpversion打印编译器版本(例如,3.0)——不要做任何其他事情。

The same works for following compilers/aliases:

这同样适用于以下编译器/别名:

cc -dumpversion
g++ -dumpversion
clang -dumpversion
tcc -dumpversion

回答by Eric Postpischil

The tools supplied by Apple have been switched from GCC to Clang. The gcc command is linked to clang as a convenience. In OS X 10.9, you do not have GCC on your system unless you have installed it independently of Apple packages.

Apple 提供的工具已经从 GCC 切换到 Clang。为方便起见,gcc 命令链接到 clang。在 OS X 10.9 中,除非您独立于 Apple 软件包安装 GCC,否则您的系统上没有 GCC。

回答by Yokey21

gcc -dumpversion | cut -f1 -f2 -f3 -d.