簡體   English   中英

Android NDK和C ++ STL

[英]Android NDK and C++ STL

在為iOS項目編譯我的C ++時,所有進展都很順利。 但是,我在Android上遇到了困難。

我的Application.mk讀取:

APP_ABI := armeabi armeabi-v7a
APP_PLATFORM := android-11
APP_STL := stlport_shared

所有LOCAL_SRC_FILES都已定義。

當我嘗試構建我的模塊時,我得到以下編譯器錯誤:

jni/Game.hpp: In member function 'const std::pair<pos, Obj*>* MyEnumerator::next()':
jni/Game.hpp:126:23: error: expected type-specifier
jni/Game.hpp:126:23: error: cannot convert 'int*' to 'std::pair<pos, Obj*>*' in assignment
jni/Game.hpp:126:23: error: expected ';'

上面提到的代碼行如下:

this->ptr = new pair<pos, Obj*>::pair(it->first, it->second);

這里, ptr是對類型pair<pos, Obj*>*pos是結構。 我已聲明using std::pair;

關於什么是錯的任何提示,以及嘗試什么?

嘗試將行更改為:

this->ptr = new std::pair<pos, Obj*>(it->first, it->second);

恕我直言,失去使用指令並使用完全限定名稱。 它干凈,精確,不允許命名碰撞。 如果必須使用它們,請不要在頭文件中使用它們,只在實現文件中使用它們。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM