Issue
When I compile with ndk-build, it shows an error message:
warning: format '%zd' expects argument of type 'signed size_t', but argument 5 has type 'ssize_t'.
I thought ssize_t
was the same as signed size_t
, am I wrong?
Solution
In Android, size_t
is unsigned int
, but ssize_t
is long int
. To print or log ssize_t
, simply use "%ld".
See 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. http://b/8253769.
Note that on other platforms, using %zd
is prefferable.
Answered By - Alex Cohn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.