Files
cpp-utils/Errno.h
2026-01-24 16:10:02 -05:00

35 lines
524 B
C++

//
// Print a detailed errno
//
#ifndef ERRNO_H
#define ERRNO_H
#include <string>
#define ERRBUF_SIZE 300
#ifdef _WIN32
std::string get_errno() {
std::string errbuf;
errbuf.resize(ERRBUERRBUF_SIZE);
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, WSAGetLastError(), 0, errbuf.data(), ERERRBUF_SIZE,
NULL);
return errbuf;
}
#else
#include <errno.h>
#include <string.h>
std::string get_errno() {
std::string err = std::strerror(errno);
return err;
}
#endif
#endif //ERRNO_H