mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Fix build on Android NDK
where XSI-compliant version of strerror_r is used violating the docs at http://linux.die.net/man/3/strerror_r
This commit is contained in:
parent
b4eef59100
commit
bdeffc3fdc
@ -134,7 +134,13 @@ int safe_strerror(
|
|||||||
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT(true) {
|
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT(true) {
|
||||||
assert(buffer != 0 && buffer_size != 0);
|
assert(buffer != 0 && buffer_size != 0);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
#ifdef _GNU_SOURCE
|
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || __ANDROID__
|
||||||
|
// XSI-compliant version of strerror_r.
|
||||||
|
result = strerror_r(error_code, buffer, buffer_size);
|
||||||
|
if (result != 0)
|
||||||
|
result = errno;
|
||||||
|
#elif _GNU_SOURCE
|
||||||
|
// GNU-specific version of strerror_r.
|
||||||
char *message = strerror_r(error_code, buffer, buffer_size);
|
char *message = strerror_r(error_code, buffer, buffer_size);
|
||||||
// If the buffer is full then the message is probably truncated.
|
// If the buffer is full then the message is probably truncated.
|
||||||
if (message == buffer && strlen(buffer) == buffer_size - 1)
|
if (message == buffer && strlen(buffer) == buffer_size - 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user