Originally Posted by
Codeplug
>> I don't think that is correct. ...
>> $ gcc -v ...
Never used it myself, but if clang were being used, I would expect the command line to use "clang" instead of "gcc".
gg
Right. I didn't even know I had the "clang" command. Mac's a bit of a mess compiler wise. See:
Code:
$ cat /tmp/a.c
#define F2(x, y) x##y
#define F1(x, y) F2(x, y)
#define TEST(x) F1(x, __COUNTER__)
TEST(abc)
TEST(abc)
Now the info about the available compilers:
Code:
$ ls -al /usr/bin/gcc
lrwxr-xr-x 1 root wheel 12 24 Oct 13:52 /usr/bin/gcc -> llvm-gcc-4.2
$ ls -al /usr/bin/clang
-rwxr-xr-x 1 root wheel 21622640 24 Oct 13:52 /usr/bin/clang
$ clang -v
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.0
Thread model: posix
$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
As for the compilation:
Code:
$ clang -E /tmp/a.c
# 1 "/tmp/a.c"
# 1 "/tmp/a.c" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 147 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "/tmp/a.c" 2
abc0
abc1
And:
Code:
$ llvm-gcc -E /tmp/a.c
# 1 "/tmp/a.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/tmp/a.c"
abc__COUNTER__
abc__COUNTER__
So I do have "LLVM" and "clang" separately, where clang works fine and LLVM doesn't.
I thought clang was part of LLVM, but now I don't know what LLVM is even supposed to be anymore. It seems to simply be an old version of gcc, though... Apple's compiler infrastructure is a mess... I guess I'll just stop using that compiler (or whatever it may be).
Thanks for your replies, guys!