Error numbers
From cppreference.com
Each of the macros defined in <cerrno>
expands to integer constant expressions with type int, each with a positive value, matching most of the POSIX error codes. The following constants are defined (the implementation may define more, as long as they begin with 'E' followed by digits or uppercase letters)
Defined in header
<cerrno> |
|
Argument list too long (macro constant) |
|
Permission denied (macro constant) |
|
Address in use (macro constant) |
|
Address not available (macro constant) |
|
Address family not supported (macro constant) |
|
Resource unavailable, try again (macro constant) |
|
Connection already in progress (macro constant) |
|
Bad file descriptor (macro constant) |
|
Bad message (macro constant) |
|
Device or resource busy (macro constant) |
|
Operation canceled (macro constant) |
|
No child processes (macro constant) |
|
Connection aborted (macro constant) |
|
Connection refused (macro constant) |
|
Connection reset (macro constant) |
|
Resource deadlock would occur (macro constant) |
|
Destination address required (macro constant) |
|
Mathematics argument out of domain of function (macro constant) |
|
File exists (macro constant) |
|
Bad address (macro constant) |
|
File too large (macro constant) |
|
Host is unreachable (macro constant) |
|
Identifier removed (macro constant) |
|
Illegal byte sequence (macro constant) |
|
Operation in progress (macro constant) |
|
Interrupted function (macro constant) |
|
Invalid argument (macro constant) |
|
I/O error (macro constant) |
|
Socket is connected (macro constant) |
|
Is a directory (macro constant) |
|
Too many levels of symbolic links (macro constant) |
|
File descriptor value too large (macro constant) |
|
Too many links (macro constant) |
|
Message too large (macro constant) |
|
Filename too long (macro constant) |
|
Network is down (macro constant) |
|
Connection aborted by network (macro constant) |
|
Network unreachable (macro constant) |
|
Too many files open in system (macro constant) |
|
No buffer space available (macro constant) |
|
No message is available on the STREAM head read queue (macro constant) |
|
No such device (macro constant) |
|
No such file or directory (macro constant) |
|
Executable file format error (macro constant) |
|
No locks available (macro constant) |
|
Link has been severed (macro constant) |
|
Not enough space (macro constant) |
|
No message of the desired type (macro constant) |
|
Protocol not available (macro constant) |
|
No space left on device (macro constant) |
|
No STREAM resources (macro constant) |
|
Not a STREAM (macro constant) |
|
Function not supported (macro constant) |
|
The socket is not connected (macro constant) |
|
Not a directory (macro constant) |
|
Directory not empty (macro constant) |
|
State not recoverable (macro constant) |
|
Not a socket (macro constant) |
|
Not supported (macro constant) |
|
Inappropriate I/O control operation (macro constant) |
|
No such device or address (macro constant) |
|
Operation not supported on socket (macro constant) |
|
Value too large to be stored in data type (macro constant) |
|
Previous owner died (macro constant) |
|
Operation not permitted (macro constant) |
|
Broken pipe (macro constant) |
|
Protocol error (macro constant) |
|
Protocol not supported (macro constant) |
|
Protocol wrong type for socket (macro constant) |
|
Result too large (macro constant) |
|
Read-only file system (macro constant) |
|
Invalid seek (macro constant) |
|
No such process (macro constant) |
|
Stream ioctl() timeout (macro constant) |
|
Connection timed out (macro constant) |
|
Text file busy (macro constant) |
|
Operation would block (macro constant) |
|
Cross-device link (macro constant) |
All values are required to be unique except that the values of EOPNOTSUPP
and ENOTSUP
may be identical and the values of EAGAIN
and EWOULDBLOCK
may be identical
[edit] Example
Run this code
#include <iostream> #include <cmath> #include <cerrno> #include <cstring> #include <clocale> int main() { double not_a_number = std::log(-1.0); if (errno == EDOM) { std::cout << "log(-1) failed: " << std::strerror(errno) << '\n'; std::setlocale(LC_MESSAGES, "de_DE.utf8"); std::cout << "Or, in German, " << std::strerror(errno) << '\n'; } }
Possible output:
log(-1) failed: Numerical argument out of domain Or, in German, Das numerische Argument ist ausserhalb des Definitionsbereiches
[edit] See also
(C++11)
|
the std::error_condition enumeration listing all standard <cerrno> macro constants (class) |
macro which expands to POSIX-compatible thread-local error number variable (macro variable) |
|
displays a character string corresponding of the current error to stderr (function) |
|
returns a text version of a given error code (function) |
|
C documentation for Error numbers
|