7

Android NDKで定義されているhash_mapを使用しようとしていますが、「非推奨の警告」が表示されます。

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]

また、「unordered_map」はgnu-libstdc ++ / 4.6 /include/とgnu-libstdc++/ 4.6 / include / tr1 /に存在するため、使用する方法があると思います。

ポイントは見つからないということです。次のうちどれが正しいものですか(もしあれば):

#include <tr1/unordered_map.h>

#include <unordered_map>

そして、それをどのように使用するのですか?__gnu_cxx :: unordered_mapが認識されません...そして、この情報を見つける方法がわかりません。

4

2 に答える 2

5

C ++ 11のサポートが必要ない/必要ない場合は、以下を使用してSTLPortのサポートを使用できます。

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

これは、STLPortがtr1名前空間内にunordered_mapを定義しているが、STLPortヘッダーが/tr1/フォルダー内にないためです。

于 2013-12-08T12:11:21.063 に答える
2

最終的に、AndroidプロジェクトにC++11サポートを追加する方法を見つけました。私たちがそれを知っているときはかなり簡単ですが、私はそれを理解するのに少し時間がかかりました。STLPortもBoostも必要ありませんでした。C ++ 11が統合されると、次のように「unordered_map」を使用できるようになります。

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

ここで、AndroidでC++11サポートを有効にする方法を説明する新しい質問を作成しました。

于 2013-03-22T07:09:55.517 に答える