Answer the question
In order to leave comments, you need to log in
Android NDK Error: no matching member function for call to 'push_back'?
There was a problem while porting my game to android. The Android NDK compiler complains about this line:
if(b==13) rock.push_back({(uint16_t)(x*64),(uint16_t)(y*64),0,0});
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:externalNativeBuildDebug'.
> Build command failed.
Error while executing process /Android/NDK/ndk-build with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/media/files/Android/project/app/jni/Android.mk NDK_APPLICATION_MK=/media/files/Android/project/app/jni/Application.mk APP_ABI=mips NDK_ALL_ABIS=mips NDK_DEBUG=1 APP_PLATFORM=android-14 NDK_OUT=/media/files/Android/project/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=/media/files/Android/project/app/build/intermediates/ndkBuild/debug/lib APP_PLATFORM=android-14 /media/files/Android/project/app/build/intermediates/ndkBuild/debug/obj/local/mips/libmain.so}
/media/files/Android/NDK/build/core/setup-app.mk:81: Android NDK: Application targets deprecated ABI(s): mips
/media/files/Android/NDK/build/core/setup-app.mk:82: Android NDK: Support for these ABIs will be removed in a future NDK release.
Android NDK: WARNING: Unsupported source file extensions in /media/files/Android/project/app/jni/src/Android.mk for module main
Android NDK: FC/SDL_FontCache.h
[mips] Compile++ : main <= main.cpp
In file included from /media/files/Android/project/app/jni/src/main.cpp:1:
In file included from /media/files/Android/project/app/jni/src/include.h:113:
/media/files/Android/project/app/jni/src/game.cpp:45:39: error: no matching member function for call to 'push_back'
if(b==13) rock.push_back({(uint16_t)(x*64),(uint16_t)(y*64),0,0});
~~~~~^~~~~~~~~
/media/files/Android/NDK/sources/cxx-stl/llvm-libc++/include/vector:677:36: note: candidate function not viable: cannot convert initializer list argument to 'const std::__ndk1::__vector_base<rck, std::__ndk1::allocator<rck> >::value_type' (aka 'const rck')
_LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
^
/media/files/Android/NDK/sources/cxx-stl/llvm-libc++/include/vector:680:36: note: candidate function not viable: cannot convert initializer list argument to 'std::__ndk1::vector<rck, std::__ndk1::allocator<rck> >::value_type' (aka 'rck')
_LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
^
class rck{
public:
unsigned short x,y;
void show();
int tm=0;
uint8_t type=0;
};
//////////////////////
std::vector<rck> rock;
Answer the question
In order to leave comments, you need to log in
class rck{
public:
unsigned short x,y;
void show();
int tm=0;
uint8_t type=0;
};
struct rck final
{
uint16_t x = 0;
uint16_t y = 0;
int32_t tm = 0;
uint8_t type = 0;
void show();
};
tm
initialized type
.rock.push_back({(uint16_t)(x*64),(uint16_t)(y*64),0,0});
push_back
, a fictitious one is formed std::initializer_list<uint16_t>
with two elements inside. rck
. tm
and type
). Each following standard of the requirement to aggregate initialization only toughens. rck
is defined for the type, and the type is not an aggregate. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question