mirror of
https://github.com/jslightham/cpp-utils.git
synced 2026-03-09 18:12:26 +01:00
35 lines
524 B
C++
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
|