gpt4 book ai didi

android - 'signed size_t' 与 'ssize_t' 不同吗?

转载 作者:行者123 更新时间:2023-11-29 16:04:24 27 4
gpt4 key购买 nike

当我使用 ndk-build 编译时,它显示一条错误消息:

warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'ssize_t'.

我认为 ssize_tsigned size_t 相同,我错了吗?

最佳答案

在Android中,size_tunsigned int,而ssize_tlong int。要打印或记录 ssize_t,只需使用 "%ld"

参见 sys/types.h :

Traditionally, bionic's ssize_t was long int. This caused GCC to emit warnings when you pass a ssize_t to a printf()-style function. The correct type is __kernel_ssize_t, which is int, which isn't an ABI change for C code (because they're the same size) but is an ABI change for C++ because int and long int mangle to i and l respectively. So until we can fix the ABI, this change should not be propagated to the NDK.

请注意,在其他平台上,使用%zdpreferable .

关于android - 'signed size_t' 与 'ssize_t' 不同吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20744349/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com