1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 21:17:28 +03:00
mold/strerror.cc
Marc-Antoine Perennou 4fc27d2195 fix build with libc++
Otherwise fails with:

/usr/include/c++/v1/__threading_support:370:43: error: use of undeclared identifier 'PTHREAD_MUTEX_RECURSIVE'

200809L triggers __USE_XOPEN2K8 to be defined which enables pthread.h to
define the missing identifier.

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2022-01-24 14:29:03 +01:00

21 lines
426 B
C++

// GNU's strerror_r is different from POSIX's strerror_r.
// In this file, we explicitly undefine _GNU_SOURCE to always
// use the POSIX version.
#define _POSIX_C_SOURCE 200809L
#undef _GNU_SOURCE
#include <cstring>
#include <errno.h>
#include <string_view>
namespace mold {
std::string_view errno_string() {
static thread_local char buf[200];
strerror_r(errno, buf, sizeof(buf));
return buf;
}
} // namespace mold