_vscprintf相当于在Android? [英] _vscprintf equivalent on Android?

查看:215
本文介绍了_vscprintf相当于在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

_vscprintf 是不是在Android。此外 vsprintf中(NULL,格式化,AP)不工作(生产赛格故障),因此似乎没有办法计算所需的vsnprintf缓冲区的大小,才能成功?

_vscprintf is not available on Android. Also vsprintf(NULL, fmt, ap) does not work (produces seg fault), so there seems to be no way of calculating size of buffer required for vsnprintf to succeed?

Android的来源表明, __ android_log_print 函数仅使用截断字符串1024 vsnprintf ...

Android sources indicate that __android_log_print function just truncates strings to 1024 using vsnprintf...

你是如何处理这种情况?

How do you handle this scenario?

推荐答案

第[7.19.6.13] -The vsprintf中 C99的标准功能,并不说明该输出缓冲器可 NULL

Section [7.19.6.13]—The vsprintf function—of the C99 Standard does not state that the output buffer may be NULL.

您可能想使用 vsnprintf

int len = vsnprintf(NULL, 0, fmt, ap)

如果呼叫成功,则返回值是,将已写入如果缓冲区足够大时,不包括NUL终止的字符数。这就像 _vscprintf ,其中还没有包括NUL终止其计数。

If the call is successful, the return value is the number of characters that would have been written if the buffer were large enough, excluding the NUL terminator. This is like _vscprintf, which also does not include the NUL terminator in its count.

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

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