std::to_string is not memember of std android

cmake 构建就没这个问题

c++库的问题

  • (https://developer.android.com/ndk/guides/cpp-support?hl=zh-cn)
  • 使用NDK-BUILD 直接构建:
AAtransMBP:android lijin$ /Users/lijin/Library/Android/sdk/ndk-bundle/ndk-build 
Android NDK: WARNING: APP_STL gnustl_static is deprecated and will be removed in the next release. Please switch to either c++_static or c++_shared. See https://developer.android.com/ndk/guides/cpp-support.html for more information.    

双重保险

  • Application.mk 里
APP_STL := c++_static
APP_CPPFLAGS := -frtti -fexceptions -std=c++11
APP_ABI := armeabi-v7a
APP_PLATFORM := android-21
  • gralde 里
        ndk {
            moduleName "ccsdk"
            abiFilter "armeabi-v7a"
            stl "c++_static"
            ldLibs "log"
        }

如果怕有风险

#include 
#include 

#if defined(__ANDROID__)
#define TO_STRING to_stringAndroid

template <typename T>
inline std::string to_stringAndroid(T value)
{
    std::ostringstream os ;
    os << value ;
    return os.str() ;
}


#else

#define TO_STRING std::to_string

#endif

你可能感兴趣的:(Android)