_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.