Ken
Ken

Reputation: 31161

Android NDK and C++ STL

When compiling my C++ for an iOS project, all proceeds just fine. However, I'm encountering difficulties on Android.

My Application.mk reads:

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

All the LOCAL_SRC_FILES are defined.

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. I've declared using std::pair;.

Any hints on what is wrong, and what to try?

Upvotes: 4

Views: 1040

Answers (1)

Jonathan Henson
Jonathan Henson

Reputation: 8206

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.

Upvotes: 4

Related Questions