How can I understand what standard my libraries are and to what standard gcc compiles in my computer?

一笑奈何 提交于 2019-12-13 13:23:09

问题


This is from my terminal:

Korays-MacBook-Pro:~ koraytugay$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix

There are 3 C standards as far as I know, ANSI C, C99 and C11.

How can I know which library I have and what my compiler supports?


回答1:


You have to find the documentation for your compiler and/or operating system and it's not always clearly documented.


Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn)

This corresponds to Xcode 6.3.

https://developer.apple.com/library/mac/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html

Also anything in the LLVM 3.5 release should be in this version of the compiler: the compiler is 'based on the llvm 3.6 svn branch, which exists prior to LLVM.org's 3.6 release (a bit confusing, I know).

http://clang.llvm.org/cxx_status.html

They don't have a similar handy page for C version support, however.

http://llvm.org/releases/3.5.0/tools/clang/docs/UsersManual.html#differences-between-various-standard-modes

In fact it looks to me like the documentation doesn't even accurately reflect clang 3.5's C11 support.


So basically, if the documentation doesn't clearly cover it, you just have to be familiar with the compiler.

Xcode 6.3 supports C language features for C89/C90, C94, C99, and C11. I believe OS X offers full library support up to C99. OS X does not include an implementation of the C11 standard library, however some C11 headers may be provided by the compiler. <threads.h> isn't, however.




回答2:


Clang support all three standards and more (“gnu99” from GCC, …). You can find out in the documentation of the commandline option -std which is used to choose them.




回答3:


http://clang.llvm.org/docs/UsersManual.html#id39

Use the -std command-line flag, e.g. -std=c11 or -std=c++11 to select the standard.



来源:https://stackoverflow.com/questions/29609659/how-can-i-understand-what-standard-my-libraries-are-and-to-what-standard-gcc-com

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!