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)
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>
.
Add both the following parameters to clang++:
-std=c++11 -stdlib=libc++
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 use boost/tr1/unordered_map.hpp
if cross platform or multiple compiler compilation is necessary for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With