当它出现这样的错误时,它是否可靠?

时间:2014-03-31 09:04:47

标签: c++ boost

这是我得到的那种错误,这绝对与我的代码无关

/usr/bin/c++  -D_TIMER -g -I/usr/local/Cellar/boost/1.54.0/include -I/Users/issam/include   -o output.o -c project.cpp
In file included from project.cpp:756:
In file included from /Users/issam/include/project.hpp:123:
In file included from /usr/local/Cellar/boost/1.54.0/include/boost/regex.hpp:31:
In file included from /usr/local/Cellar/boost/1.54.0/include/boost/regex/v4/regex.hpp:39:
In file included from /usr/local/Cellar/boost/1.54.0/include/boost/regex/regex_traits.hpp:27:
In file included from /usr/local/Cellar/boost/1.54.0/include/boost/regex/v4/regex_traits.hpp:39:
In file included from /usr/local/Cellar/boost/1.54.0/include/boost/regex/v4/cpp_regex_traits.hpp:40:
/usr/local/Cellar/boost/1.54.0/include/boost/regex/pending/object_cache.hpp:39:17: error: no type named 'list' in namespace 'std'
   typedef std::list<value_type> list_type;
           ~~~~~^

如果我编译的文件只包括:

#include "boost/regex.hpp"

它编译没有任何问题,并创建.o文件。这是编译

的详细输出
/usr/bin/c++  -D_TIMER -g -I/usr/local/Cellar/boost/1.54.0/include -o output.o -c newFile.cpp -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.5.0
Thread model: posix
 "/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.8.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name newFile.cpp -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 136 -v -g -coverage-file /Users/issam/folder/output.o -resource-dir /usr/bin/../lib/clang/4.2 -D _TIMER -I /usr/local/Cellar/boost/1.54.0/include -fmodule-cache-path /var/folders/pd/kcfk19hd5mv9vjwsvpqtk_tc0000gq/T/clang-module-cache -fdeprecated-macro -fdebug-compilation-dir /Users/issam/folder -ferror-limit 19 -fmessage-length 168 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.8.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o output.o -x c++ newFile.cpp
clang -cc1 version 4.2 based upon LLVM 3.2svn default target x86_64-apple-darwin12.5.0
ignoring nonexistent directory "/usr/include/c++/4.2.1/i686-apple-darwin10/x86_64"
ignoring nonexistent directory "/usr/include/c++/4.0.0"
ignoring nonexistent directory "/usr/include/c++/4.0.0/i686-apple-darwin8/"
ignoring nonexistent directory "/usr/include/c++/4.0.0/backward"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/Cellar/boost/1.54.0/include
 /usr/include/c++/4.2.1
 /usr/include/c++/4.2.1/backward
 /usr/local/include
 /usr/bin/../lib/clang/4.2/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)

2 个答案:

答案 0 :(得分:4)

boost/regex/pending/object_cache.hpp在第23行有以下内容:

#include <list>

因此,对于"error: no type named 'list' in namespace 'std'"之类的错误,您的Boost或编译器工具链的安装可能会出现问题。

如果您尝试编译仅包含:

的C ++源文件,会发生什么
#include "boost/regex.hpp"

答案 1 :(得分:3)

我查了一下 - mentioned header文件包含<list>,所以一切都很好。

有可能通过在命名空间中包含boost/regex.hpp或您自己的project.hpp或在任一标头的#include之前使用指令来搞乱命名空间。

编译器会在实际看到错误的位置告诉您错误,在这种情况下,位于boost标头深处的某处。通常情况下,当出现错误时,您不会立即注意到它,但是当事情看起来搞砸之后很久。这次对于编译器来说是一样的。它无法准确地说你搞砸了,但只有它知道的东西是错误的。