Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/error/errno macros"

From cppreference.com
< cpp‎ | error
m (See also: nomono, langlinks)
Line 6: Line 6:
 
{{dsc begin}}
 
{{dsc begin}}
 
{{dsc header | cerrno}}
 
{{dsc header | cerrno}}
{{dsc macro const | E2BIG            | nolink=true| notes={{mark c++11}}| Argument list too long }}
+
{{dsc macro const | E2BIG            | nolink=true| Argument list too long}}
{{dsc macro const | EACCES          | nolink=true| notes={{mark c++11}}| Permission denied}}
+
{{dsc macro const | EACCES          | nolink=true| Permission denied}}
{{dsc macro const | EADDRINUSE      | nolink=true| notes={{mark c++11}}| Address in use}}
+
{{dsc macro const | EADDRINUSE      | nolink=true| Address in use}}
{{dsc macro const | EADDRNOTAVAIL    | nolink=true| notes={{mark c++11}}| Address not available}}
+
{{dsc macro const | EADDRNOTAVAIL    | nolink=true| Address not available}}
{{dsc macro const | EAFNOSUPPORT    | nolink=true| notes={{mark c++11}}| Address family not supported}}
+
{{dsc macro const | EAFNOSUPPORT    | nolink=true| Address family not supported}}
{{dsc macro const | EAGAIN          | nolink=true| notes={{mark c++11}}| Resource unavailable, try again}}
+
{{dsc macro const | EAGAIN          | nolink=true| Resource unavailable, try again}}
{{dsc macro const | EALREADY        | nolink=true| notes={{mark c++11}}| Connection already in progress}}
+
{{dsc macro const | EALREADY        | nolink=true| Connection already in progress}}
{{dsc macro const | EBADF            | nolink=true| notes={{mark c++11}}| Bad file descriptor}}
+
{{dsc macro const | EBADF            | nolink=true| Bad file descriptor}}
{{dsc macro const | EBADMSG          | nolink=true| notes={{mark c++11}}| Bad message}}
+
{{dsc macro const | EBADMSG          | nolink=true| Bad message}}
{{dsc macro const | EBUSY            | nolink=true| notes={{mark c++11}}| Device or resource busy}}
+
{{dsc macro const | EBUSY            | nolink=true| Device or resource busy}}
{{dsc macro const | ECANCELED        | nolink=true| notes={{mark c++11}}| Operation canceled}}
+
{{dsc macro const | ECANCELED        | nolink=true| Operation canceled}}
{{dsc macro const | ECHILD          | nolink=true| notes={{mark c++11}}| No child processes}}
+
{{dsc macro const | ECHILD          | nolink=true| No child processes}}
{{dsc macro const | ECONNABORTED    | nolink=true| notes={{mark c++11}}| Connection aborted}}
+
{{dsc macro const | ECONNABORTED    | nolink=true| Connection aborted}}
{{dsc macro const | ECONNREFUSED    | nolink=true| notes={{mark c++11}}| Connection refused}}
+
{{dsc macro const | ECONNREFUSED    | nolink=true| Connection refused}}
{{dsc macro const | ECONNRESET      | nolink=true| notes={{mark c++11}}| Connection reset}}
+
{{dsc macro const | ECONNRESET      | nolink=true| Connection reset}}
{{dsc macro const | EDEADLK          | nolink=true| notes={{mark c++11}}| Resource deadlock would occur}}
+
{{dsc macro const | EDEADLK          | nolink=true| Resource deadlock would occur}}
{{dsc macro const | EDESTADDRREQ    | nolink=true| notes={{mark c++11}}| Destination address required}}
+
{{dsc macro const | EDESTADDRREQ    | nolink=true| Destination address required}}
{{dsc macro const | EDOM            | nolink=true                     | Mathematics argument out of domain of function}}
+
{{dsc macro const | EDOM            | nolink=true| Mathematics argument out of domain of function}}
{{dsc macro const | EEXIST          | nolink=true| notes={{mark c++11}}| File exists}}
+
{{dsc macro const | EEXIST          | nolink=true| File exists}}
{{dsc macro const | EFAULT          | nolink=true| notes={{mark c++11}}| Bad address}}
+
{{dsc macro const | EFAULT          | nolink=true| Bad address}}
{{dsc macro const | EFBIG            | nolink=true| notes={{mark c++11}}| File too large}}
+
{{dsc macro const | EFBIG            | nolink=true| File too large}}
{{dsc macro const | EHOSTUNREACH    | nolink=true| notes={{mark c++11}}| Host is unreachable}}
+
{{dsc macro const | EHOSTUNREACH    | nolink=true| Host is unreachable}}
{{dsc macro const | EIDRM            | nolink=true| notes={{mark c++11}}| Identifier removed}}
+
{{dsc macro const | EIDRM            | nolink=true| Identifier removed}}
{{dsc macro const | EILSEQ          | nolink=true| notes={{mark c++11}}| Illegal byte sequence}}
+
{{dsc macro const | EILSEQ          | nolink=true| Illegal byte sequence}}
{{dsc macro const | EINPROGRESS      | nolink=true| notes={{mark c++11}}| Operation in progress}}
+
{{dsc macro const | EINPROGRESS      | nolink=true| Operation in progress}}
{{dsc macro const | EINTR            | nolink=true| notes={{mark c++11}}| Interrupted function}}
+
{{dsc macro const | EINTR            | nolink=true| Interrupted function}}
{{dsc macro const | EINVAL          | nolink=true| notes={{mark c++11}}| Invalid argument}}
+
{{dsc macro const | EINVAL          | nolink=true| Invalid argument}}
{{dsc macro const | EIO              | nolink=true| notes={{mark c++11}}| I/O error}}
+
{{dsc macro const | EIO              | nolink=true| I/O error}}
{{dsc macro const | EISCONN          | nolink=true| notes={{mark c++11}}| Socket is connected}}
+
{{dsc macro const | EISCONN          | nolink=true| Socket is connected}}
{{dsc macro const | EISDIR          | nolink=true| notes={{mark c++11}}| Is a directory}}
+
{{dsc macro const | EISDIR          | nolink=true| Is a directory}}
{{dsc macro const | ELOOP            | nolink=true| notes={{mark c++11}}| Too many levels of symbolic links}}
+
{{dsc macro const | ELOOP            | nolink=true| Too many levels of symbolic links}}
{{dsc macro const | EMFILE          | nolink=true| notes={{mark c++11}}| File descriptor value too large}}
+
{{dsc macro const | EMFILE          | nolink=true| File descriptor value too large}}
{{dsc macro const | EMLINK          | nolink=true| notes={{mark c++11}}| Too many links}}
+
{{dsc macro const | EMLINK          | nolink=true| Too many links}}
{{dsc macro const | EMSGSIZE        | nolink=true| notes={{mark c++11}}| Message too large}}
+
{{dsc macro const | EMSGSIZE        | nolink=true| Message too large}}
{{dsc macro const | ENAMETOOLONG    | nolink=true| notes={{mark c++11}}| Filename too long}}
+
{{dsc macro const | ENAMETOOLONG    | nolink=true| Filename too long}}
{{dsc macro const | ENETDOWN        | nolink=true| notes={{mark c++11}}| Network is down}}
+
{{dsc macro const | ENETDOWN        | nolink=true| Network is down}}
{{dsc macro const | ENETRESET        | nolink=true| notes={{mark c++11}}| Connection aborted by network}}
+
{{dsc macro const | ENETRESET        | nolink=true| Connection aborted by network}}
{{dsc macro const | ENETUNREACH      | nolink=true| notes={{mark c++11}}| Network unreachable}}
+
{{dsc macro const | ENETUNREACH      | nolink=true| Network unreachable}}
{{dsc macro const | ENFILE          | nolink=true| notes={{mark c++11}}| Too many files open in system}}
+
{{dsc macro const | ENFILE          | nolink=true| Too many files open in system}}
{{dsc macro const | ENOBUFS          | nolink=true| notes={{mark c++11}}| No buffer space available}}
+
{{dsc macro const | ENOBUFS          | nolink=true| No buffer space available}}
{{dsc macro const | ENODATA          | nolink=true| notes={{mark c++11}}| No message is available on the STREAM head read queue}}
+
{{dsc macro const | ENODATA          | nolink=true| No message is available on the STREAM head read queue}}
{{dsc macro const | ENODEV          | nolink=true| notes={{mark c++11}}| No such device}}
+
{{dsc macro const | ENODEV          | nolink=true| No such device}}
{{dsc macro const | ENOENT          | nolink=true| notes={{mark c++11}}| No such file or directory}}
+
{{dsc macro const | ENOENT          | nolink=true| No such file or directory}}
{{dsc macro const | ENOEXEC          | nolink=true| notes={{mark c++11}}| Executable file format error}}
+
{{dsc macro const | ENOEXEC          | nolink=true| Executable file format error}}
{{dsc macro const | ENOLCK          | nolink=true| notes={{mark c++11}}| No locks available}}
+
{{dsc macro const | ENOLCK          | nolink=true| No locks available}}
{{dsc macro const | ENOLINK          | nolink=true| notes={{mark c++11}}| Link has been severed}}
+
{{dsc macro const | ENOLINK          | nolink=true| Link has been severed}}
{{dsc macro const | ENOMEM          | nolink=true| notes={{mark c++11}}| Not enough space}}
+
{{dsc macro const | ENOMEM          | nolink=true| Not enough space}}
{{dsc macro const | ENOMSG          | nolink=true| notes={{mark c++11}}| No message of the desired type}}
+
{{dsc macro const | ENOMSG          | nolink=true| No message of the desired type}}
{{dsc macro const | ENOPROTOOPT      | nolink=true| notes={{mark c++11}}| Protocol not available}}
+
{{dsc macro const | ENOPROTOOPT      | nolink=true| Protocol not available}}
{{dsc macro const | ENOSPC          | nolink=true| notes={{mark c++11}}| No space left on device}}
+
{{dsc macro const | ENOSPC          | nolink=true| No space left on device}}
{{dsc macro const | ENOSR            | nolink=true| notes={{mark c++11}}| No STREAM resources}}
+
{{dsc macro const | ENOSR            | nolink=true| No STREAM resources}}
{{dsc macro const | ENOSTR          | nolink=true| notes={{mark c++11}}| Not a STREAM}}
+
{{dsc macro const | ENOSTR          | nolink=true| Not a STREAM}}
{{dsc macro const | ENOSYS          | nolink=true| notes={{mark c++11}}| Function not supported}}
+
{{dsc macro const | ENOSYS          | nolink=true| Function not supported}}
{{dsc macro const | ENOTCONN        | nolink=true| notes={{mark c++11}}| The socket is not connected}}
+
{{dsc macro const | ENOTCONN        | nolink=true| The socket is not connected}}
{{dsc macro const | ENOTDIR          | nolink=true| notes={{mark c++11}}| Not a directory}}
+
{{dsc macro const | ENOTDIR          | nolink=true| Not a directory}}
{{dsc macro const | ENOTEMPTY        | nolink=true| notes={{mark c++11}}| Directory not empty}}
+
{{dsc macro const | ENOTEMPTY        | nolink=true| Directory not empty}}
{{dsc macro const | ENOTRECOVERABLE  | nolink=true| notes={{mark c++11}}| State not recoverable}}
+
{{dsc macro const | ENOTRECOVERABLE  | nolink=true| State not recoverable}}
{{dsc macro const | ENOTSOCK        | nolink=true| notes={{mark c++11}}| Not a socket}}
+
{{dsc macro const | ENOTSOCK        | nolink=true| Not a socket}}
{{dsc macro const | ENOTSUP          | nolink=true| notes={{mark c++11}}| Not supported}}
+
{{dsc macro const | ENOTSUP          | nolink=true| Not supported}}
{{dsc macro const | ENOTTY          | nolink=true| notes={{mark c++11}}| Inappropriate I/O control operation}}
+
{{dsc macro const | ENOTTY          | nolink=true| Inappropriate I/O control operation}}
{{dsc macro const | ENXIO            | nolink=true| notes={{mark c++11}}| No such device or address}}
+
{{dsc macro const | ENXIO            | nolink=true| No such device or address}}
{{dsc macro const | EOPNOTSUPP      | nolink=true| notes={{mark c++11}}| Operation not supported on socket}}
+
{{dsc macro const | EOPNOTSUPP      | nolink=true| Operation not supported on socket}}
{{dsc macro const | EOVERFLOW        | nolink=true| notes={{mark c++11}}| Value too large to be stored in data type}}
+
{{dsc macro const | EOVERFLOW        | nolink=true| Value too large to be stored in data type}}
{{dsc macro const | EOWNERDEAD      | nolink=true| notes={{mark c++11}}| Previous owner died}}
+
{{dsc macro const | EOWNERDEAD      | nolink=true| Previous owner died}}
{{dsc macro const | EPERM            | nolink=true| notes={{mark c++11}}| Operation not permitted}}
+
{{dsc macro const | EPERM            | nolink=true| Operation not permitted}}
{{dsc macro const | EPIPE            | nolink=true| notes={{mark c++11}}| Broken pipe}}
+
{{dsc macro const | EPIPE            | nolink=true| Broken pipe}}
{{dsc macro const | EPROTO          | nolink=true| notes={{mark c++11}}| Protocol error}}
+
{{dsc macro const | EPROTO          | nolink=true| Protocol error}}
{{dsc macro const | EPROTONOSUPPORT  | nolink=true| notes={{mark c++11}}| Protocol not supported}}
+
{{dsc macro const | EPROTONOSUPPORT  | nolink=true| Protocol not supported}}
{{dsc macro const | EPROTOTYPE      | nolink=true| notes={{mark c++11}}| Protocol wrong type for socket}}
+
{{dsc macro const | EPROTOTYPE      | nolink=true| Protocol wrong type for socket}}
{{dsc macro const | ERANGE          | nolink=true|                       Result too large}}
+
{{dsc macro const | ERANGE          | nolink=true| Result too large}}
{{dsc macro const | EROFS            | nolink=true| notes={{mark c++11}}| Read-only file system}}
+
{{dsc macro const | EROFS            | nolink=true| Read-only file system}}
{{dsc macro const | ESPIPE          | nolink=true| notes={{mark c++11}}| Invalid seek}}
+
{{dsc macro const | ESPIPE          | nolink=true| Invalid seek}}
{{dsc macro const | ESRCH            | nolink=true| notes={{mark c++11}}| No such process}}
+
{{dsc macro const | ESRCH            | nolink=true| No such process}}
{{dsc macro const | ETIME            | nolink=true| notes={{mark c++11}}| Stream ioctl() timeout}}
+
{{dsc macro const | ETIME            | nolink=true| Stream ioctl() timeout}}
{{dsc macro const | ETIMEDOUT        | nolink=true| notes={{mark c++11}}| Connection timed out}}
+
{{dsc macro const | ETIMEDOUT        | nolink=true| Connection timed out}}
{{dsc macro const | ETXTBSY          | nolink=true| notes={{mark c++11}}| Text file busy}}
+
{{dsc macro const | ETXTBSY          | nolink=true| Text file busy}}
{{dsc macro const | EWOULDBLOCK      | nolink=true| notes={{mark c++11}}| Operation would block}}
+
{{dsc macro const | EWOULDBLOCK      | nolink=true| Operation would block}}
{{dsc macro const | EXDEV            | nolink=true| notes={{mark c++11}}| Cross-device link}}
+
{{dsc macro const | EXDEV            | nolink=true| Cross-device link}}
 
{{dsc end}}
 
{{dsc end}}
 +
  
 
All values are required to be unique except that the values of {{tt|EOPNOTSUPP}} and {{tt|ENOTSUP}} may be identical and the values of {{tt|EAGAIN}} and {{tt|EWOULDBLOCK}} may be identical
 
All values are required to be unique except that the values of {{tt|EOPNOTSUPP}} and {{tt|ENOTSUP}} may be identical and the values of {{tt|EAGAIN}} and {{tt|EWOULDBLOCK}} may be identical

Revision as of 23:33, 12 July 2021

 
 
 

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>
E2BIG
Argument list too long
(macro constant)
EACCES
Permission denied
(macro constant)
EADDRINUSE
Address in use
(macro constant)
EADDRNOTAVAIL
Address not available
(macro constant)
EAFNOSUPPORT
Address family not supported
(macro constant)
EAGAIN
Resource unavailable, try again
(macro constant)
EALREADY
Connection already in progress
(macro constant)
EBADF
Bad file descriptor
(macro constant)
EBADMSG
Bad message
(macro constant)
EBUSY
Device or resource busy
(macro constant)
ECANCELED
Operation canceled
(macro constant)
ECHILD
No child processes
(macro constant)
ECONNABORTED
Connection aborted
(macro constant)
ECONNREFUSED
Connection refused
(macro constant)
ECONNRESET
Connection reset
(macro constant)
EDEADLK
Resource deadlock would occur
(macro constant)
EDESTADDRREQ
Destination address required
(macro constant)
EDOM
Mathematics argument out of domain of function
(macro constant)
EEXIST
File exists
(macro constant)
EFAULT
Bad address
(macro constant)
EFBIG
File too large
(macro constant)
EHOSTUNREACH
Host is unreachable
(macro constant)
EIDRM
Identifier removed
(macro constant)
EILSEQ
Illegal byte sequence
(macro constant)
EINPROGRESS
Operation in progress
(macro constant)
EINTR
Interrupted function
(macro constant)
EINVAL
Invalid argument
(macro constant)
EIO
I/O error
(macro constant)
EISCONN
Socket is connected
(macro constant)
EISDIR
Is a directory
(macro constant)
ELOOP
Too many levels of symbolic links
(macro constant)
EMFILE
File descriptor value too large
(macro constant)
EMLINK
Too many links
(macro constant)
EMSGSIZE
Message too large
(macro constant)
ENAMETOOLONG
Filename too long
(macro constant)
ENETDOWN
Network is down
(macro constant)
ENETRESET
Connection aborted by network
(macro constant)
ENETUNREACH
Network unreachable
(macro constant)
ENFILE
Too many files open in system
(macro constant)
ENOBUFS
No buffer space available
(macro constant)
ENODATA
No message is available on the STREAM head read queue
(macro constant)
ENODEV
No such device
(macro constant)
ENOENT
No such file or directory
(macro constant)
ENOEXEC
Executable file format error
(macro constant)
ENOLCK
No locks available
(macro constant)
ENOLINK
Link has been severed
(macro constant)
ENOMEM
Not enough space
(macro constant)
ENOMSG
No message of the desired type
(macro constant)
ENOPROTOOPT
Protocol not available
(macro constant)
ENOSPC
No space left on device
(macro constant)
ENOSR
No STREAM resources
(macro constant)
ENOSTR
Not a STREAM
(macro constant)
ENOSYS
Function not supported
(macro constant)
ENOTCONN
The socket is not connected
(macro constant)
ENOTDIR
Not a directory
(macro constant)
ENOTEMPTY
Directory not empty
(macro constant)
ENOTRECOVERABLE
State not recoverable
(macro constant)
ENOTSOCK
Not a socket
(macro constant)
ENOTSUP
Not supported
(macro constant)
ENOTTY
Inappropriate I/O control operation
(macro constant)
ENXIO
No such device or address
(macro constant)
EOPNOTSUPP
Operation not supported on socket
(macro constant)
EOVERFLOW
Value too large to be stored in data type
(macro constant)
EOWNERDEAD
Previous owner died
(macro constant)
EPERM
Operation not permitted
(macro constant)
EPIPE
Broken pipe
(macro constant)
EPROTO
Protocol error
(macro constant)
EPROTONOSUPPORT
Protocol not supported
(macro constant)
EPROTOTYPE
Protocol wrong type for socket
(macro constant)
ERANGE
Result too large
(macro constant)
EROFS
Read-only file system
(macro constant)
ESPIPE
Invalid seek
(macro constant)
ESRCH
No such process
(macro constant)
ETIME
Stream ioctl() timeout
(macro constant)
ETIMEDOUT
Connection timed out
(macro constant)
ETXTBSY
Text file busy
(macro constant)
EWOULDBLOCK
Operation would block
(macro constant)
EXDEV
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

Example

#include <cerrno>
#include <clocale>
#include <cmath>
#include <cstring>
#include <iostream>
 
int main()
{
    const double not_a_number = std::log(-1.0);
    std::cout << not_a_number << '\n';
 
    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:

nan
log(-1) failed: Numerical argument out of domain
Or, in German, Das numerische Argument ist ausserhalb des Definitionsbereiches

See also

(C++11)
the std::error_condition enumeration listing all standard <cerrno> macro constants
(class) [edit]
macro which expands to POSIX-compatible thread-local error number variable
(macro variable)[edit]
displays a character string corresponding of the current error to stderr
(function) [edit]
returns a text version of a given error code
(function) [edit]
C documentation for Error numbers