7

I am trying to use a hash_map, defined in the Android NDK, but I get a "deprecation warning":

ndk/sources/cxx-stl/gnu-libstdc++/4.6/include/ext/../backward/backward_warning.h:33:2:
error: #warning This file includes at least one deprecated or antiquated header which may 
be removed without further notice at a future date. Please use a non-deprecated interface 
with equivalent functionality instead. For a listing of replacement headers and 
interfaces, consult the file backward_warning.h. To disable this warning use -Wno-
deprecated. [-Werror=cpp]

And since "unordered_map" is present in gnu-libstdc++/4.6/include/ and also in gnu-libstdc++/4.6/include/tr1/, I believe that there is a way to use it.

The point is that I cannot find it. Which of the following is the right one (if any):

#include <tr1/unordered_map.h>

#include <unordered_map>

And then, how to use it? __gnu_cxx::unordered_map is not recognized... and I don't know how to find this information.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95

2 Answers2

5

In case you don't want/need C++11 support, you can use the one from the STLPort using:

// Here we are referencing the stlport one:
#include <unordered_map>
...
std::tr1::unordered_map<int, int> test;

That's because STLPort defines unordered_map inside tr1 namespace, but the STLPort header is not inside any /tr1/ folder.

2

I eventually found a way by adding C++11 support in my Android project. Pretty easy when we know it, but I took some time to figure it out. Neither STLPort nor Boost were needed. Once C++11 was integrated, I could use "unordered_map" as follows:

#include <unordered_map>
...
std::unordered_map<int, int> test;

I created a new question to explain how to enable C++11 support in Android here.

Community
  • 1
  • 1
JonasVautherin
  • 7,297
  • 6
  • 49
  • 95