简体   繁体   English

Android NDK和C ++ STL

[英]Android NDK and C++ STL

When compiling my C++ for an iOS project, all proceeds just fine. 在为iOS项目编译我的C ++时,所有进展都很顺利。 However, I'm encountering difficulties on Android. 但是,我在Android上遇到了困难。

My Application.mk reads: 我的Application.mk读取:

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

All the LOCAL_SRC_FILES are defined. 所有LOCAL_SRC_FILES都已定义。

When I try to build my module I get the following compiler error: 当我尝试构建我的模块时,我得到以下编译器错误:

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 ';'

The line of code referred to above reads: 上面提到的代码行如下:

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

Here, ptr is of type pair<pos, Obj*>* and pos is a struct. 这里, ptr是对类型pair<pos, Obj*>*pos是结构。 I've declared using std::pair; 我已声明using std::pair; .

Any hints on what is wrong, and what to try? 关于什么是错的任何提示,以及尝试什么?

try changing the line to read: 尝试将行更改为:

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

Also IMHO, lose the using directives and use fully qualified names. 恕我直言,失去使用指令并使用完全限定名称。 It is clean, precise, and doesn't allow for naming collisions. 它干净,精确,不允许命名碰撞。 If you must use them, don't use them in header files, just in your implementation files. 如果必须使用它们,请不要在头文件中使用它们,只在实现文件中使用它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM