【发布时间】:2012-03-16 06:06:53
【问题描述】:
我有一个使用 g++ 4.6 构建我的项目的 makefile。
#specify the compiler
GXX=g++ -std=c++0x
# Specifiy the target
all: linkedList
# Specify the object files that the target depends on
# Also specify the object files needed to create the executable
linkedList: StudentRecord.o Node.o LinkedList.o ListMain.o
$(GXX) StudentRecord.o Node.o LinkedList.o ListMain.o -o linkedList
# Specify how the object files should be created from source files
LinkedList.o: LinkedList.cpp
$(GXX) -c LinkedList.cpp
ListMain.o: ListMain.cpp
$(GXX) -c ListMain.cpp
StudentRecord.o: StudentRecord.cpp
$(GXX) -c StudentRecord.cpp
Node.o: Node.cpp
$(GXX) -c Node.cpp
当我将第一行更改为 GXX = clang++ -std=c++0x 时,clang 会抛出一些关于 iostream 找不到正确的 args 或之后出现的许多其他错误的相当密集的错误(但这是“根”错误)。
In file included from /usr/include/c++/4.6/iostream:39:
In file included from /usr/include/c++/4.6/ostream:39:
In file included from /usr/include/c++/4.6/ios:40:
In file included from /usr/include/c++/4.6/bits/char_traits.h:40:
In file included from /usr/include/c++/4.6/bits/stl_algobase.h:65:
In file included from /usr/include/c++/4.6/bits/stl_pair.h:60:
In file included from /usr/include/c++/4.6/bits/move.h:53:
/usr/include/c++/4.6/type_traits:630:59: error: '_Tp' does not refer to a value
: public integral_constant<bool, __is_standard_layout(_Tp)>
这是我的 makefile 的问题,还是这个简单的编译真的有区别?
使用 clang 2.9。
注意: clang 抱怨的线路是#include <iostream>
【问题讨论】:
-
我不是 C++ 专家,但this page 似乎表明 clang 2.9 还没有 100% 为 c++0x 做好准备——也许这是问题的一部分?
-
它不会在 c++0x 问题上崩溃,我认为它在包含 iostream 时会崩溃
-
错误消息中的路径看起来像是您获取的是 g++4.6 的头文件,而不是 clang 的头文件。 g++ 头文件倾向于使用 gcc 特定的扩展和可能不适用于 clang 的东西。
-
添加 -v 标志让 clang 打印出它使用的所有参数。然后您可以手动运行这些命令并更改选项以查看是否可以构建单个翻译单元,如果可以,则更改生成文件以使用您发现的设置。