当我尝试在我的机器上编译以下简单的 C++11 代码时遇到了一个奇怪的问题:
#include <boost/thread/thread.hpp>
它编译得很好,g++ foo.cpp -o foo but chokes on 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 v10.7.4 (Lion) 和 GCC 4.7.1。