Android NDK and C ++ STL

When compiling my C ++ for an iOS project, everything is going fine. However, I run into difficulties on Android.

My Application.mk reads:

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

All LOCAL_SRC_FILES are defined.

When I try to create 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 the code above says:

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

Here ptr is of type pair<pos, Obj*>* , and pos is a structure. I declared using std::pair; .

Any hints of what's wrong and what to try?

+4
source share
1 answer

try changing the line as follows:

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

Also IMHO, lose use directives and use fully qualified names. It is clean, more precisely, and does not allow name collisions. If you must use them, do not use them in header files, just in your implementation files.

+4
source

All Articles