为什么有些包含文件只驻留在 tr1 中?
当我尝试包含
之类的内容时,它会失败并表示该文件不存在,而当我尝试包含
时,它会起作用。然而,c++03 中也存在包含文件,并且是 c++11(例如
具有移动构造函数)。此外,也可以正常找到仅在 c++11 中而不在 tr1 中的标头,例如
。
就像 tr1 中的所有新内容都被放入 tr1 文件夹中,而其他所有内容都放入正常包含中。
为什么会发生这种情况?有没有办法在不修改源文件的情况下修复它?
传递 -I/path/to/include/tr1
不起作用,因为所有内容都在 tr1 命名空间中。
我正在使用的编译器是
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
When I try to include things like <unordered_map>
it fails and says the file doesn't exist, while when I try to include <tr1/unordered_map>
it works. however, the include files that are present also in c++03 are found, and are c++11 (like <vector>
has move constructor). Also, headers that are only in c++11 and not in tr1 are found normally as well, like <thread>
.
Its like everything that was new in tr1 was just thrown into tr1 folder and everything else into normal include.
Why is this happening? Is there any fix to it without modifying source files?
Passing -I/path/to/include/tr1
won't work because everything is in the tr1 namespace.
The compiler I'm using is
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
TR1(技术报告1)不是标准,而仅仅是一份报告。这是让人们知道委员会对这一领域感兴趣的官方方式。任何 tr1 实现都是实验性版本,旨在获取现场反馈以改进未来标准。
使用 Apple 的 Xcode 4.2,您可以通过搜索“libc++”的构建设置来选择几乎完整的 C++11 库,然后选择“libc++”作为 C++ 标准库(它不是默认值)。
或者,如果您更喜欢命令行,可以使用 -stdlib=libc++。
libc++ 不包含任何 tr1 组件,但包含除
之外的所有 C++11。TR1 (technical report 1) is not a standard, but merely a report. It is an official way of letting people know that the committee is interested in this area. Any tr1 implementation is an experimental release aimed at getting field feedback for the purpose of bettering a future standard.
Using Apple's Xcode 4.2 you can choose a nearly complete C++11 library by searching your build settings for "libc++" and then choose "libc++" as the C++ Standard Library (it is not the default).
Or if you prefer the command line you can -stdlib=libc++.
libc++ does not contain any tr1 components, but does contain all of C++11 except for
<atomic>
.将以下参数添加到 clang++ 中:
Add both the following parameters to clang++:
是的,不同的编译器以不同的方式对待 TR1 标头。例如,GCC 会执行与您经历的相同的操作,而 MVS 接受
。如果您需要跨平台或多编译器编译,解决此问题的一种方法是使用boost/tr1/unordered_map.hpp
。Yes different compilers treat TR1 headers differently. GCC for example does the same thing that you experienced whereas MVS accepts
<unordered_map>
. One way to work around it is to useboost/tr1/unordered_map.hpp
if cross platform or multiple compiler compilation is necessary for you.