Xcode 使用哪个 C/C++ 编译器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16697699/
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
Which C/C++ compiler does Xcode use?
提问by wowpatrick
I just started to get my hands dirty with C/C++, and I am still getting my head around the different concepts (I've written mostly Java previously). I'd really like to know which C/C++ compiler is used and also which standard library is included. Also, I'd like to know where I can find the API documentation of the respective standard library (like the Java SE API docs).
我刚刚开始接触 C/C++,我仍然在思考不同的概念(我以前主要是用 Java 编写的)。我真的很想知道使用了哪个 C/C++ 编译器以及包含哪个标准库。另外,我想知道在哪里可以找到相应标准库的 API 文档(如 Java SE API 文档)。
采纳答案by Vite Falcon
I'm not an XCode user, but it seems to be Apple's LLVM Compiler (by default) according to Apple's website: https://developer.apple.com/technologies/tools/. But, I guess, like any other IDE XCode does support other compilers like GCC. Also depends on your XCode version it seems: http://useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html
我不是 XCode 用户,但根据 Apple 的网站:https: //developer.apple.com/technologies/tools/,它似乎是 Apple 的 LLVM 编译器(默认情况下)。但是,我想,像任何其他 IDE 一样,XCode 确实支持其他编译器,如 GCC。似乎还取决于您的 XCode 版本:http: //useyourloaf.com/blog/2011/03/21/compiler-options-in-xcode-gcc-or-llvm.html
Here's a question in SO that asks about the default compiler and the answer seems to have the code to find just that: In Xcode 4.5, what is "Compiler Default" for "C++ Standard Library" and "C++ Language Dialect"?
这是 SO 中的一个问题,询问默认编译器,答案似乎有代码可以找到:在 Xcode 4.5 中,“C++ 标准库”和“C++ 语言方言”的“编译器默认值”是什么?
According to this post 4.6 uses clang instead of GCC for C++: http://cplusplusmusings.wordpress.com/2013/02/26/c-and-xcode-4-6/
根据这篇文章,4.6 使用 clang 而不是 GCC for C++:http: //cplusplusmusings.wordpress.com/2013/02/26/c-and-xcode-4-6/
P.S.: Googling does help ;)
PS:谷歌搜索确实有帮助;)
回答by wowpatrick
For C++:
对于 C++:
Xcode 4.6.2 uses the Clang C++ compiler frontend with LLVM as backend which is conform to the C++11 standart and uses libc++ as the standart library.
Xcode 4.6.2 使用 Clang C++ 编译器前端,LLVM 作为后端,符合 C++11 标准并使用 libc++ 作为标准库。
Hereyou can finde a apple presentation about libc++.
在这里你可以找到关于 libc++ 的苹果演示。
回答by Forbin
I just noticed the second half of the question was never really answered:
我只是注意到问题的后半部分从未真正得到回答:
... I'd like to know where I can find the API documentation of the respective standard library ...
... 我想知道在哪里可以找到相应标准库的 API 文档 ...
A simple Google search will reveal a wealth of information about this. Do note, however, that the "C++ Standard Library" is notthe same thing as the "C Standard Library," so be careful of that when searching and reading. C++ has its roots in C, but the two have diverged to become separate languages that share a lot of commonality -- and a lot of hidden differences.
一个简单的谷歌搜索将揭示大量关于这方面的信息。 确实注意到,但是,在“C ++标准库”是不一样的东西为“C标准库,”搜索和阅读时要小心一点。C++ 起源于 C,但两者已经分化为独立的语言,它们具有许多共同点——以及许多隐藏的差异。
The canonical reference work regarding this is titled, appropriately enough, "The C++ Standard Library" by Nicolai M. Josuttis, published by Addison-Wesley. Many C++ programmers keep this on their bookshelves as a reference.
关于这方面的规范参考工作的标题是“C++ 标准库”,作者是 Nicolai M. Josuttis,由 Addison-Wesley 出版。许多 C++ 程序员将其放在书架上作为参考。
There is a good online reference for the library at https://cppreference.com/.
在https://cppreference.com/ 上有一个很好的图书馆在线参考资料。
If you are interested in specifics of the LLVM implementation used by Apple's Xcode, see https://libcxx.llvm.org/.
如果您对 Apple 的 Xcode 使用的 LLVM 实现的细节感兴趣,请参阅https://libcxx.llvm.org/。
For a comprehensive list of the most highly recommended books and references for C++, Stack Overflow already has a very good FAQ regarding this: The Definitive C++ Book Guide and List.
对于 C++ 最强烈推荐的书籍和参考资料的完整列表,Stack Overflow 已经有一个非常好的常见问题解答:The Definitive C++ Book Guide and List。