Android的NDK的std :: to_string支持 [英] Android ndk std::to_string support

查看:2376
本文介绍了Android的NDK的std :: to_string支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了android NDK r9d和工具链4.8,但我不能够使用std :: to_string函数,编译器会引发这个错误:

I'm using android NDK r9d and toolchain 4.8 but I'm not able to use std::to_string function, compiler throws this error:

 error: 'to_string' is not a member of 'std'

不支持在Android NDK这个功能呢?我尝试 APP_CPPFLAGS:= = -std C ++ 11 没有运气

推荐答案

您可以尝试 LOCAL_CFLAGS:= = -std C ++ 11 ,但似乎<一个href=\"http://stackoverflow.com/questions/17950814/how-to-use-stdstoul-and-stdstoull-in-android/18124627#18124627\">several字符串函数没有可用于Android NDK 。

另一种方法是自己实现它。

The alternative is to implement it yourself.

#include <string>
#include <sstream>

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

int main()
{
    std::string perfect = to_string(5) ;
}

这篇关于Android的NDK的std :: to_string支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆