Clang and the default compiler in OS X Lion

。_饼干妹妹 提交于 2019-11-27 01:25:22

问题


In OS X Snow Leopard (10.6) I used the following lines in ~/.bashrc to force compilation with clang instead of standard gcc:

# Set Clang as the default compiler for the system
export CC=clang
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

I also (occasionally) had to use the following lines to use llvm-gcc when clang would fail to compile certain things (PostgreSQL was guilty of this for a long time):

# Set LLVM GCC as the default compiler for the system
export CPP='llvm-gcc-4.2'
export CC='llvm-gcc-4.2'
export CXX='llvm-g++'

On OS X Lion (10.7), are these lines still required? Is llvm-gcc (or clang) the default compiler for the system? Or will these lines still need to live in my ~/.bashrc?


回答1:


gcc is symlinked to llvm-gcc-4.2 on Lion.

lrwxr-xr-x 1 root wheel 12 Jul 21 20:51 /usr/bin/gcc -> llvm-gcc-4.2

lrwxr-xr-x 1 root wheel 12 Jul 21 20:51 /usr/bin/g++ -> llvm-g++-4.2

You can probably remove those environment variables without much harm.




回答2:


The default compiler on Lion is now llvm-gcc-4.2, although the standard selection (gcc-4.2, llvm-gcc-4.2, clang) remains unchanged from Snow Leopard. Try reading Using the right compiler.



来源:https://stackoverflow.com/questions/6796982/clang-and-the-default-compiler-in-os-x-lion

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