当我尝试在我的机器上编译以下简单的c ++ 11代码时,我遇到了一个奇怪的问题:
#include <boost/thread/thread.hpp>
使用g ++ foo.cpp -o foo进行编译,但是对g ++ -c -std = c ++ 11 foo.cpp -o foo进行了扼流,并出现以下错误:
In file included from /usr/local/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/functional:56:0,
from /usr/local/lib/gcc/x86_64-apple-darwin11.4.0/4.7.1/../../../../include/c++/4.7.1/memory:81,
from /usr/local/include/boost/config/no_tr1/memory.hpp:21,
from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:27,
from /usr/local/include/boost/shared_ptr.hpp:17,
from /usr/local/include/boost/thread/pthread/thread_data.hpp:10,
from /usr/local/include/boost/thread/thread.hpp:17,
from foo.cpp:1:
./tuple:1:1: error: stray ‘\317’ in program
./tuple:1:1: error: stray ‘\372’ in program
./tuple:1:1: error: stray ‘\355’ in program
./tuple:1:1: error: stray ‘\376’ in program
... Additional lines omitted
我很茫然。特别是因为我已经能够在没有任何问题的情况下再次编译其他程序c ++ 11。有任何想法吗?提前致谢。我正在运行OS X.7.4和gcc 4.7.1
答案 0 :(得分:4)
那是因为您在当前目录中有一个名为tuple
的文件,而不是标准tuple
标头。可能是因为编译行中有一些-I.
。
错误消息中的strays字符只是文件的第一个字节,不在允许的字符集中,以八进制显示。