mirror of
https://github.com/jslightham/cpp-utils.git
synced 2026-03-09 18:12:26 +01:00
Initial commit
This commit is contained in:
34
Errno.h
Normal file
34
Errno.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// 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
|
||||
Reference in New Issue
Block a user