llvm


Xcode 4 でデフォルトになった LLVM って何?

ざっくりとした結論から言ってしまえば、Xcode における LLVM は従来のデフォルトコンパイラである GCC を置き換えるものです。LLVM には次のような特徴があります。

コンパイルが速い
コンパイルされたコードが速い
・エラーメッセージがわかりやすい
・他のツールと連携しやすい

いいことばかりですね。

らしい。。
ちなみに、下記のリストをコンパイルしてみました。

$ clang test.c としました。


リスト1

void ThreadProc(void *lpVoid)
{
	static __thread int *lpThis;
	static  int *lpThis2;
	int     a;
	
	if(a=1) {printf("ohayou");}

}

下記が、結果です。

test.c:3:9: error: thread-local storage is unsupported for the current target
        static __thread int *lpThis;
               ^
test.c:7:6: warning: using the result of an assignment as a condition without
      parentheses [-Wparentheses]
        if(a=1) {printf("ohayou");}
           ~^~
test.c:7:6: note: place parentheses around the assignment to silence this
      warning
        if(a=1) {printf("ohayou");}
            ^
           (  )
test.c:7:6: note: use '==' to turn this assignment into an equality comparison
        if(a=1) {printf("ohayou");}
            ^
            ==
test.c:7:11: warning: implicitly declaring C library function 'printf' with type
      'int (const char *, ...)'
        if(a=1) {printf("ohayou");}
                 ^
test.c:7:11: note: please include the header  or explicitly provide a
      declaration for 'printf'
2 warnings and 1 error generated.


こんなに、事細かく、警告やエラーが出るとは。。(;・∀・)

すごいなぁ。。

ちょっと、くどいけどね。。(^^;;