简体   繁体   中英

NDK r16b std::istringstream doesn't behave as expected

I have an app which its native code was compiled using NDK r12b. But now I want to migrate to NDK r16b.

I use the standalone toolchain to compile my app (both for r12b and r16b). the arguments that I used to make the toolchain is:

make_standalone_toolchain.py --arch arm --api 15 --stl libc++

after using r16b, i found that std::istringstream doesn't split whitespace-separated numbers like " 0.4 0.5 ". the output of istringstream is still " 0.4 0.6 " instead of 0.4 and 0.6.

also, if there's a minus sign (-) it will split the input, for example: "armeabi-v7a" will become "armeabi" and "v7a". while when i use r12b the istringstream won't split and will output "armeabi-v7a". I used this snippet to check:

const char* input = " 0.4 0.5 "
std::istringstream iss(input);
__android_log_print(ANDROID_LOG_INFO, "myTag","istringstream input = %s", input);
for (std::istream_iterator<std::string> it = std::istream_iterator<std::string>(iss); it != std::istream_iterator<std::string>(); it++)
{
    __android_log_print(ANDROID_LOG_INFO, "myTag", "istringstream content = %s", it->c_str() ? it->c_str() : "NULL");
}

I used clang as the compiler and these are the command line that i used:

compile options:

-fsigned-char
-fno-exceptions
-fno-rtti
-pipe
-ferror-limit=1000
-stdlib=libc++
-std=c++11
-D__ANDROID_API__=15
-mfpu=vfpv3-d16
-mfloat-abi=softfp
-target armv7a-none-linux-androideabi
-marm
-march=armv7-a
-mtune=generic-armv7-a
--sysroot $NDK_Root$/sysroot
-g
-O0

Link options:

-lOpenSLES
-lGLESv2
-lEGL
-latomic
-landroid
-llog
-lm
-lz
-ldl
-lc++_shared
-lgcc
-lc
-Wl,--build-id
-target armv7a-none-linux-androideabi
-no-canonical-prefixes
-march=armv7-a
-Wl,--fix-cortex-a8
-Wl,-z,noexecstack
-Wl,--no-undefined
-Wl,-z,relro
-Wl,-z,now
-nostdlib
--sysroot $NDK_Root$/sysroot

Anyone can give me insight on why is this happens? Thank you.

As it turns out, I was copying libc++_shared.so from NDK r12b to my APK and that's is the cause of that weird behaviour.

That was stupid, i conclude the case closed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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