Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c

gcc

standards

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?

like image 753
Koray Tugay Avatar asked Dec 14 '22 15:12

Koray Tugay


2 Answers

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.

like image 53
bames53 Avatar answered Dec 21 '22 22:12

bames53


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.

like image 21
Pascal Cuoq Avatar answered Dec 21 '22 23:12

Pascal Cuoq