Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Adding new compilers to Xcode 4.6.3

I want to update Xcode 4.6.3 with C11 support. I've thus far downloaded, built, and installed gcc 4.9 (using make install from source code from one of the mirrors linked to by the GNU website), but I'm not sure how to actually add the compiler to Xcode's list in a project's build options. Any advice?

Xcode-OTHER, OS X Mountain Lion (10.8.4)

Posted on Jun 26, 2013 7:46 PM

Reply
7 replies

Jun 27, 2013 3:16 AM in response to etresoft

Then how does one enable C11 in Xcode? The avaiable dialects for both LLVM 4.2 and LLVM GCC 4.2 (the two compilers available) are ANSI C, GNU 89, GNU 99, C89 and C99, and when I try to add something exclusive to C11 (say, threads.h) to a project, I get an error saying the file can't be found.

Further, what do you mean, "GCC has never been fully supported on the Mac?" It's a GNU project, meaning it's supposed to work with any Unix-based system; GCC 4.2 is also a native option in Xcode.

Jun 27, 2013 3:38 AM in response to WanderingCoder

http://llvm.org/releases/3.1/docs/ClangReleaseNotes.html#cchanges


Use -std=c11 or -std=gnu11


With any of these new language versions, not all features may be available. Threads.h appears to be yet another wrapper around everyone's favourite pthreads. I strongly suggest looking at Apple's Grand Central Dispatch instead. It is a complete re-think of using concurrency.


GNU has nothing to do with UNIX. OS X is a certified UNIX operating system. Linux is not. The GNU tool chain has always relied on Apple's code to do the low-level work. In OS X, GCC is strictly for backwards-compatibility. Clang is the future.

Jun 27, 2013 12:15 PM in response to etresoft

I tried running "clang -std=c11" in the terminal, but clang returns "error: no input files" (I guess it's a compile-time command). I see no option under C dialects in Xcode for -std=c11 or -std=gnu11 (although all the others - c89, c99, ansi) are there.

And I know Unix isn't partnered with GNU or anything, but the GNU manifesto states that a GNU programmer should always focus on coding with Unix compatibility in mind.

Jun 27, 2013 1:11 PM in response to WanderingCoder


WanderingCoder wrote:


I tried running "clang -std=c11" in the terminal, but clang returns "error: no input files" (I guess it's a compile-time command).




Yes. It needs a source file.


I see no option under C dialects in Xcode for -std=c11 or -std=gnu11 (although all the others - c89, c99, ansi) are there.


I seem to have it:


User uploaded file

It seems to work well enough. Supposedly this is using a C11 construct:


#include <stdio.h>


int main(int argc, const char * argv[])

{

struct T { int tag; union { float x; int n; }; };



// insert code here...


printf("Hello, World! %ld\n", __STDC_VERSION__);

return 0;

}


The output says it is C11:


Hello, World! 201112


And I know Unix isn't partnered with GNU or anything, but the GNU manifesto states that a GNU programmer should always focus on coding with Unix compatibility in mind.

They do have a bunch of manifestos over there don't they?


It looks like <threads.h> might be the only thing missing from the current 4.6.3 version of Xcode: http://clang.llvm.org/cxx_status.html


Perhaps it is available in Xcode5. I don't think you are getting much with that. GCD is infinitely better.

Adding new compilers to Xcode 4.6.3

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.