[英]How can i make my C++ code buildable with clang on Mac?
I have a bunch of .cpp and .c files and i use gcc/make to build a project. 我有一堆.cpp和.c文件,我使用gcc / make来构建项目。 On Mac there is only gcc 4.2.
在Mac上只有gcc 4.2。 It is very old and puts a lot of limitations on the language.
它很老,对语言有很多限制。 I've heard clang is the default compiler for Mac.
我听说clang是Mac的默认编译器。 How can i change my makefiles to use clang?
我如何更改我的makefile以使用clang?
For starters, GCC 4.2 is not "very old and puts a lot of limitations on the language." 对于初学者来说,GCC 4.2并不是“很老,并且在语言上有很多限制”。
That being said, your Mac, if it has GCC 4.2 installed, should also have clang
installed. 话虽如此,如果您的Mac已安装GCC 4.2,则还应该安装
clang
。 Xcode includes both clang and GCC (built with LLVM), as clang
and gcc
/ g++
respectively. Xcode包含clang和GCC(使用LLVM构建),分别作为
clang
和gcc
/ g++
。 Either: 或者:
clang
directly clang
CC
environment variable to clang
CC
环境变量设置为clang
g++
to clang
if you want to be really hamfisted about it. g++
与clang
软链接。 Any one should do the trick. 任何人都应该做到这一点。
You could try replacing CC=g++ with CC=clang in you makefiles or doing CC=clang make instead of make and see if it compiles. 您可以尝试在makefile文件中用CC = clang替换CC = g ++或执行CC = clang make而不是make并查看其是否可以编译。
If you use gnu c/c++ extensions or gcc command line options it may not compile, in that case you can try googling for help. 如果您使用gnu c / c ++扩展名或gcc命令行选项,则它们可能无法编译,在这种情况下,您可以尝试使用Google搜索来寻求帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.