Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | error
(sync)
m (Example: +new example; the previous one remains present where relevant, e.g. here.)
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 
{{title|Error numbers}}
 
{{title|Error numbers}}
{{cpp/error/sidebar}}
+
{{cpp/error/navbar}}
  
Each of the macros defined in {{tt|<cerrno>}} expands to integer constant expressions with type {{cpp|int}}, each with a positive value, matching most of the [http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html POSIX error codes]. The following constants are defined (the implementation may define more, as long as they begin with {{cpp|'E'}} followed by digits or uppercase letters)
+
Each of the macros defined in {{header|cerrno}} expands to integer constant expressions with type {{c|int}}, each with a positive value, matching most of the [https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html POSIX error codes]. The following constants are defined (the implementation may define more, as long as they begin with {{c/core|'E'}} followed by digits or uppercase letters).
  
{{dcl list begin}}
+
{{dsc begin}}
{{dcl list header | cerrno}}
+
{{dsc header | cerrno}}
{{dcl list macro const | E2BIG            | nolink=true| notes={{mark c++11}}| Argument list too long }}
+
{{dsc macro const | E2BIG            | nolink=true| notes={{mark c++11}}| Argument list too long }}
{{dcl list macro const | EACCES          | nolink=true| notes={{mark c++11}}| Permission denied}}
+
{{dsc macro const | EACCES          | nolink=true| notes={{mark c++11}}| Permission denied}}
{{dcl list macro const | EADDRINUSE      | nolink=true| notes={{mark c++11}}| Address in use}}
+
{{dsc macro const | EADDRINUSE      | nolink=true| notes={{mark c++11}}| Address in use}}
{{dcl list macro const | EADDRNOTAVAIL    | nolink=true| notes={{mark c++11}}| Address not available}}
+
{{dsc macro const | EADDRNOTAVAIL    | nolink=true| notes={{mark c++11}}| Address not available}}
{{dcl list macro const | EAFNOSUPPORT    | nolink=true| notes={{mark c++11}}| Address family not supported}}
+
{{dsc macro const | EAFNOSUPPORT    | nolink=true| notes={{mark c++11}}| Address family not supported}}
{{dcl list macro const | EAGAIN          | nolink=true| notes={{mark c++11}}| Resource unavailable, try again}}
+
{{dsc macro const | EAGAIN          | nolink=true| notes={{mark c++11}}| Resource unavailable, try again}}
{{dcl list macro const | EALREADY        | nolink=true| notes={{mark c++11}}| Connection already in progress}}
+
{{dsc macro const | EALREADY        | nolink=true| notes={{mark c++11}}| Connection already in progress}}
{{dcl list macro const | EBADF            | nolink=true| notes={{mark c++11}}| Bad file descriptor}}
+
{{dsc macro const | EBADF            | nolink=true| notes={{mark c++11}}| Bad file descriptor}}
{{dcl list macro const | EBADMSG          | nolink=true| notes={{mark c++11}}| Bad message}}
+
{{dsc macro const | EBADMSG          | nolink=true| notes={{mark c++11}}| Bad message}}
{{dcl list macro const | EBUSY            | nolink=true| notes={{mark c++11}}| Device or resource busy}}
+
{{dsc macro const | EBUSY            | nolink=true| notes={{mark c++11}}| Device or resource busy}}
{{dcl list macro const | ECANCELED        | nolink=true| notes={{mark c++11}}| Operation canceled}}
+
{{dsc macro const | ECANCELED        | nolink=true| notes={{mark c++11}}| Operation canceled}}
{{dcl list macro const | ECHILD          | nolink=true| notes={{mark c++11}}| No child processes}}
+
{{dsc macro const | ECHILD          | nolink=true| notes={{mark c++11}}| No child processes}}
{{dcl list macro const | ECONNABORTED    | nolink=true| notes={{mark c++11}}| Connection aborted}}
+
{{dsc macro const | ECONNABORTED    | nolink=true| notes={{mark c++11}}| Connection aborted}}
{{dcl list macro const | ECONNREFUSED    | nolink=true| notes={{mark c++11}}| Connection refused}}
+
{{dsc macro const | ECONNREFUSED    | nolink=true| notes={{mark c++11}}| Connection refused}}
{{dcl list macro const | ECONNRESET      | nolink=true| notes={{mark c++11}}| Connection reset}}
+
{{dsc macro const | ECONNRESET      | nolink=true| notes={{mark c++11}}| Connection reset}}
{{dcl list macro const | EDEADLK          | nolink=true| notes={{mark c++11}}| Resource deadlock would occur}}
+
{{dsc macro const | EDEADLK          | nolink=true| notes={{mark c++11}}| Resource deadlock would occur}}
{{dcl list macro const | EDESTADDRREQ    | nolink=true| notes={{mark c++11}}| Destination address required}}
+
{{dsc macro const | EDESTADDRREQ    | nolink=true| notes={{mark c++11}}| Destination address required}}
{{dcl list 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}}
{{dcl list macro const | EEXIST          | nolink=true| notes={{mark c++11}}| File exists}}
+
{{dsc macro const | EEXIST          | nolink=true| notes={{mark c++11}}| File exists}}
{{dcl list macro const | EFAULT          | nolink=true| notes={{mark c++11}}| Bad address}}
+
{{dsc macro const | EFAULT          | nolink=true| notes={{mark c++11}}| Bad address}}
{{dcl list macro const | EFBIG            | nolink=true| notes={{mark c++11}}| File too large}}
+
{{dsc macro const | EFBIG            | nolink=true| notes={{mark c++11}}| File too large}}
{{dcl list macro const | EHOSTUNREACH    | nolink=true| notes={{mark c++11}}| Host is unreachable}}
+
{{dsc macro const | EHOSTUNREACH    | nolink=true| notes={{mark c++11}}| Host is unreachable}}
{{dcl list macro const | EIDRM            | nolink=true| notes={{mark c++11}}| Identifier removed}}
+
{{dsc macro const | EIDRM            | nolink=true| notes={{mark c++11}}| Identifier removed}}
{{dcl list macro const | EILSEQ          | nolink=true| notes={{mark c++11}}| Illegal byte sequence}}
+
{{dsc macro const | EILSEQ          | nolink=true| notes={{mark c++11}}| Illegal byte sequence}}
{{dcl list macro const | EINPROGRESS      | nolink=true| notes={{mark c++11}}| Operation in progress}}
+
{{dsc macro const | EINPROGRESS      | nolink=true| notes={{mark c++11}}| Operation in progress}}
{{dcl list macro const | EINTR            | nolink=true| notes={{mark c++11}}| Interrupted function}}
+
{{dsc macro const | EINTR            | nolink=true| notes={{mark c++11}}| Interrupted function}}
{{dcl list macro const | EINVAL          | nolink=true| notes={{mark c++11}}| Invalid argument}}
+
{{dsc macro const | EINVAL          | nolink=true| notes={{mark c++11}}| Invalid argument}}
{{dcl list macro const | EIO              | nolink=true| notes={{mark c++11}}| I/O error}}
+
{{dsc macro const | EIO              | nolink=true| notes={{mark c++11}}| I/O error}}
{{dcl list macro const | EISCONN          | nolink=true| notes={{mark c++11}}| Socket is connected}}
+
{{dsc macro const | EISCONN          | nolink=true| notes={{mark c++11}}| Socket is connected}}
{{dcl list macro const | EISDIR          | nolink=true| notes={{mark c++11}}| Is a directory}}
+
{{dsc macro const | EISDIR          | nolink=true| notes={{mark c++11}}| Is a directory}}
{{dcl list macro const | ELOOP            | nolink=true| notes={{mark c++11}}| Too many levels of symbolic links}}
+
{{dsc macro const | ELOOP            | nolink=true| notes={{mark c++11}}| Too many levels of symbolic links}}
{{dcl list macro const | EMFILE          | nolink=true| notes={{mark c++11}}| File descriptor value too large}}
+
{{dsc macro const | EMFILE          | nolink=true| notes={{mark c++11}}| File descriptor value too large}}
{{dcl list macro const | EMLINK          | nolink=true| notes={{mark c++11}}| Too many links}}
+
{{dsc macro const | EMLINK          | nolink=true| notes={{mark c++11}}| Too many links}}
{{dcl list macro const | EMSGSIZE        | nolink=true| notes={{mark c++11}}| Message too large}}
+
{{dsc macro const | EMSGSIZE        | nolink=true| notes={{mark c++11}}| Message too large}}
{{dcl list macro const | ENAMETOOLONG    | nolink=true| notes={{mark c++11}}| Filename too long}}
+
{{dsc macro const | ENAMETOOLONG    | nolink=true| notes={{mark c++11}}| Filename too long}}
{{dcl list macro const | ENETDOWN        | nolink=true| notes={{mark c++11}}| Network is down}}
+
{{dsc macro const | ENETDOWN        | nolink=true| notes={{mark c++11}}| Network is down}}
{{dcl list macro const | ENETRESET        | nolink=true| notes={{mark c++11}}| Connection aborted by network}}
+
{{dsc macro const | ENETRESET        | nolink=true| notes={{mark c++11}}| Connection aborted by network}}
{{dcl list macro const | ENETUNREACH      | nolink=true| notes={{mark c++11}}| Network unreachable}}
+
{{dsc macro const | ENETUNREACH      | nolink=true| notes={{mark c++11}}| Network unreachable}}
{{dcl list macro const | ENFILE          | nolink=true| notes={{mark c++11}}| Too many files open in system}}
+
{{dsc macro const | ENFILE          | nolink=true| notes={{mark c++11}}| Too many files open in system}}
{{dcl list macro const | ENOBUFS          | nolink=true| notes={{mark c++11}}| No buffer space available}}
+
{{dsc macro const | ENOBUFS          | nolink=true| notes={{mark c++11}}| No buffer space available}}
{{dcl list 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| notes={{mark c++11}}| No message is available on the STREAM head read queue}}
{{dcl list macro const | ENODEV          | nolink=true| notes={{mark c++11}}| No such device}}
+
{{dsc macro const | ENODEV          | nolink=true| notes={{mark c++11}}| No such device}}
{{dcl list macro const | ENOENT          | nolink=true| notes={{mark c++11}}| No such file or directory}}
+
{{dsc macro const | ENOENT          | nolink=true| notes={{mark c++11}}| No such file or directory}}
{{dcl list macro const | ENOEXEC          | nolink=true| notes={{mark c++11}}| Executable file format error}}
+
{{dsc macro const | ENOEXEC          | nolink=true| notes={{mark c++11}}| Executable file format error}}
{{dcl list macro const | ENOLCK          | nolink=true| notes={{mark c++11}}| No locks available}}
+
{{dsc macro const | ENOLCK          | nolink=true| notes={{mark c++11}}| No locks available}}
{{dcl list macro const | ENOLINK          | nolink=true| notes={{mark c++11}}| Link has been severed}}
+
{{dsc macro const | ENOLINK          | nolink=true| notes={{mark c++11}}| Link has been severed}}
{{dcl list macro const | ENOMEM          | nolink=true| notes={{mark c++11}}| Not enough space}}
+
{{dsc macro const | ENOMEM          | nolink=true| notes={{mark c++11}}| Not enough space}}
{{dcl list macro const | ENOMSG          | nolink=true| notes={{mark c++11}}| No message of the desired type}}
+
{{dsc macro const | ENOMSG          | nolink=true| notes={{mark c++11}}| No message of the desired type}}
{{dcl list macro const | ENOPROTOOPT      | nolink=true| notes={{mark c++11}}| Protocol not available}}
+
{{dsc macro const | ENOPROTOOPT      | nolink=true| notes={{mark c++11}}| Protocol not available}}
{{dcl list macro const | ENOSPC          | nolink=true| notes={{mark c++11}}| No space left on device}}
+
{{dsc macro const | ENOSPC          | nolink=true| notes={{mark c++11}}| No space left on device}}
{{dcl list macro const | ENOSR            | nolink=true| notes={{mark c++11}}| No STREAM resources}}
+
{{dsc macro const | ENOSR            | nolink=true| notes={{mark c++11}}| No STREAM resources}}
{{dcl list macro const | ENOSTR          | nolink=true| notes={{mark c++11}}| Not a STREAM}}
+
{{dsc macro const | ENOSTR          | nolink=true| notes={{mark c++11}}| Not a STREAM}}
{{dcl list macro const | ENOSYS          | nolink=true| notes={{mark c++11}}| Function not supported}}
+
{{dsc macro const | ENOSYS          | nolink=true| notes={{mark c++11}}| Function not supported}}
{{dcl list macro const | ENOTCONN        | nolink=true| notes={{mark c++11}}| The socket is not connected}}
+
{{dsc macro const | ENOTCONN        | nolink=true| notes={{mark c++11}}| The socket is not connected}}
{{dcl list macro const | ENOTDIR          | nolink=true| notes={{mark c++11}}| Not a directory}}
+
{{dsc macro const | ENOTDIR          | nolink=true| notes={{mark c++11}}| Not a directory}}
{{dcl list macro const | ENOTEMPTY        | nolink=true| notes={{mark c++11}}| Directory not empty}}
+
{{dsc macro const | ENOTEMPTY        | nolink=true| notes={{mark c++11}}| Directory not empty}}
{{dcl list macro const | ENOTRECOVERABLE  | nolink=true| notes={{mark c++11}}| State not recoverable}}
+
{{dsc macro const | ENOTRECOVERABLE  | nolink=true| notes={{mark c++11}}| State not recoverable}}
{{dcl list macro const | ENOTSOCK        | nolink=true| notes={{mark c++11}}| Not a socket}}
+
{{dsc macro const | ENOTSOCK        | nolink=true| notes={{mark c++11}}| Not a socket}}
{{dcl list macro const | ENOTSUP          | nolink=true| notes={{mark c++11}}| Not supported}}
+
{{dsc macro const | ENOTSUP          | nolink=true| notes={{mark c++11}}| Not supported}}
{{dcl list macro const | ENOTTY          | nolink=true| notes={{mark c++11}}| Inappropriate I/O control operation}}
+
{{dsc macro const | ENOTTY          | nolink=true| notes={{mark c++11}}| Inappropriate I/O control operation}}
{{dcl list macro const | ENXIO            | nolink=true| notes={{mark c++11}}| No such device or address}}
+
{{dsc macro const | ENXIO            | nolink=true| notes={{mark c++11}}| No such device or address}}
{{dcl list macro const | EOPNOTSUPP      | nolink=true| notes={{mark c++11}}| Operation not supported on socket}}
+
{{dsc macro const | EOPNOTSUPP      | nolink=true| notes={{mark c++11}}| Operation not supported on socket}}
{{dcl list macro const | EOVERFLOW        | nolink=true| notes={{mark c++11}}| Value too large to be stored in data type}}
+
{{dsc macro const | EOVERFLOW        | nolink=true| notes={{mark c++11}}| Value too large to be stored in data type}}
{{dcl list macro const | EOWNERDEAD      | nolink=true| notes={{mark c++11}}| Previous owner died}}
+
{{dsc macro const | EOWNERDEAD      | nolink=true| notes={{mark c++11}}| Previous owner died}}
{{dcl list macro const | EPERM            | nolink=true| notes={{mark c++11}}| Operation not permitted}}
+
{{dsc macro const | EPERM            | nolink=true| notes={{mark c++11}}| Operation not permitted}}
{{dcl list macro const | EPIPE            | nolink=true| notes={{mark c++11}}| Broken pipe}}
+
{{dsc macro const | EPIPE            | nolink=true| notes={{mark c++11}}| Broken pipe}}
{{dcl list macro const | EPROTO          | nolink=true| notes={{mark c++11}}| Protocol error}}
+
{{dsc macro const | EPROTO          | nolink=true| notes={{mark c++11}}| Protocol error}}
{{dcl list macro const | EPROTONOSUPPORT  | nolink=true| notes={{mark c++11}}| Protocol not supported}}
+
{{dsc macro const | EPROTONOSUPPORT  | nolink=true| notes={{mark c++11}}| Protocol not supported}}
{{dcl list macro const | EPROTOTYPE      | nolink=true| notes={{mark c++11}}| Protocol wrong type for socket}}
+
{{dsc macro const | EPROTOTYPE      | nolink=true| notes={{mark c++11}}| Protocol wrong type for socket}}
{{dcl list macro const | ERANGE          | nolink=true|                      Result too large}}
+
{{dsc macro const | ERANGE          | nolink=true|                      Result too large}}
{{dcl list macro const | EROFS            | nolink=true| notes={{mark c++11}}| Read-only file system}}
+
{{dsc macro const | EROFS            | nolink=true| notes={{mark c++11}}| Read-only file system}}
{{dcl list macro const | ESPIPE          | nolink=true| notes={{mark c++11}}| Invalid seek}}
+
{{dsc macro const | ESPIPE          | nolink=true| notes={{mark c++11}}| Invalid seek}}
{{dcl list macro const | ESRCH            | nolink=true| notes={{mark c++11}}| No such process}}
+
{{dsc macro const | ESRCH            | nolink=true| notes={{mark c++11}}| No such process}}
{{dcl list macro const | ETIME            | nolink=true| notes={{mark c++11}}| Stream ioctl() timeout}}
+
{{dsc macro const | ETIME            | nolink=true| notes={{mark c++11}}| Stream ioctl() timeout}}
{{dcl list macro const | ETIMEDOUT        | nolink=true| notes={{mark c++11}}| Connection timed out}}
+
{{dsc macro const | ETIMEDOUT        | nolink=true| notes={{mark c++11}}| Connection timed out}}
{{dcl list macro const | ETXTBSY          | nolink=true| notes={{mark c++11}}| Text file busy}}
+
{{dsc macro const | ETXTBSY          | nolink=true| notes={{mark c++11}}| Text file busy}}
{{dcl list macro const | EWOULDBLOCK      | nolink=true| notes={{mark c++11}}| Operation would block}}
+
{{dsc macro const | EWOULDBLOCK      | nolink=true| notes={{mark c++11}}| Operation would block}}
{{dcl list macro const | EXDEV            | nolink=true| notes={{mark c++11}}| Cross-device link}}
+
{{dsc macro const | EXDEV            | nolink=true| notes={{mark c++11}}| Cross-device link}}
{{dcl list 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.
  
{{cpp/error/example_errno}}
+
===Example===
 +
{{example|code=
 +
#include <cerrno>
 +
#include <cstring>
 +
#include <iomanip>
 +
#include <iostream>
 +
 
 +
#define SHOW(x) std::cout << std::setw(15) << #x << ": " << std::strerror(x) << '\n'
 +
 
 +
int main()
 +
{
 +
    std::cout << "Known error codes/messages:\n\n";
 +
 
 +
    SHOW( E2BIG );
 +
    SHOW( EACCES );
 +
    SHOW( EADDRINUSE );
 +
    SHOW( EADDRNOTAVAIL );
 +
    SHOW( EAFNOSUPPORT );
 +
    SHOW( EAGAIN );
 +
    SHOW( EALREADY );
 +
    SHOW( EBADF );
 +
    SHOW( EBADMSG );
 +
    SHOW( EBUSY );
 +
    SHOW( ECANCELED );
 +
    SHOW( ECHILD );
 +
    SHOW( ECONNABORTED );
 +
    SHOW( ECONNREFUSED );
 +
    SHOW( ECONNRESET );
 +
    SHOW( EDEADLK );
 +
    SHOW( EDESTADDRREQ );
 +
    SHOW( EDOM );
 +
    SHOW( EEXIST );
 +
    SHOW( EFAULT );
 +
    SHOW( EFBIG );
 +
    SHOW( EHOSTUNREACH );
 +
    SHOW( EIDRM );
 +
    SHOW( EILSEQ );
 +
    SHOW( EINPROGRESS );
 +
    SHOW( EINTR );
 +
    SHOW( EINVAL );
 +
    SHOW( EIO );
 +
    SHOW( EISCONN );
 +
    SHOW( EISDIR );
 +
    SHOW( ELOOP );
 +
    SHOW( EMFILE );
 +
    SHOW( EMLINK );
 +
    SHOW( EMSGSIZE );
 +
    SHOW( ENAMETOOLONG );
 +
    SHOW( ENETDOWN );
 +
    SHOW( ENETRESET );
 +
    SHOW( ENETUNREACH );
 +
    SHOW( ENFILE );
 +
    SHOW( ENOBUFS );
 +
    SHOW( ENODATA );
 +
    SHOW( ENODEV );
 +
    SHOW( ENOENT );
 +
    SHOW( ENOEXEC );
 +
    SHOW( ENOLCK );
 +
    SHOW( ENOLINK );
 +
    SHOW( ENOMEM );
 +
    SHOW( ENOMSG );
 +
    SHOW( ENOPROTOOPT );
 +
    SHOW( ENOSPC );
 +
    SHOW( ENOSR );
 +
    SHOW( ENOSTR );
 +
    SHOW( ENOSYS );
 +
    SHOW( ENOTCONN );
 +
    SHOW( ENOTDIR );
 +
    SHOW( ENOTEMPTY );
 +
    SHOW( ENOTRECOVERABLE );
 +
    SHOW( ENOTSOCK );
 +
    SHOW( ENOTSUP );
 +
    SHOW( ENOTTY );
 +
    SHOW( ENXIO );
 +
    SHOW( EOPNOTSUPP );
 +
    SHOW( EOVERFLOW );
 +
    SHOW( EOWNERDEAD );
 +
    SHOW( EPERM );
 +
    SHOW( EPIPE );
 +
    SHOW( EPROTO );
 +
    SHOW( EPROTONOSUPPORT );
 +
    SHOW( EPROTOTYPE );
 +
    SHOW( ERANGE );
 +
    SHOW( EROFS );
 +
    SHOW( ESPIPE );
 +
    SHOW( ESRCH );
 +
    SHOW( ETIME );
 +
    SHOW( ETIMEDOUT );
 +
    SHOW( ETXTBSY );
 +
    SHOW( EWOULDBLOCK );
 +
    SHOW( EXDEV );
 +
}
 +
|p=true
 +
|output=
 +
Known error codes/messages:
 +
 
 +
          E2BIG: Argument list too long
 +
        EACCES: Permission denied
 +
    EADDRINUSE: Address already in use
 +
  EADDRNOTAVAIL: Cannot assign requested address
 +
  EAFNOSUPPORT: Address family not supported by protocol
 +
        EAGAIN: Resource temporarily unavailable
 +
      EALREADY: Operation already in progress
 +
          EBADF: Bad file descriptor
 +
        EBADMSG: Bad message
 +
          EBUSY: Device or resource busy
 +
      ECANCELED: Operation canceled
 +
        ECHILD: No child processes
 +
  ECONNABORTED: Software caused connection abort
 +
  ECONNREFUSED: Connection refused
 +
    ECONNRESET: Connection reset by peer
 +
        EDEADLK: Resource deadlock avoided
 +
  EDESTADDRREQ: Destination address required
 +
          EDOM: Numerical argument out of domain
 +
        EEXIST: File exists
 +
        EFAULT: Bad address
 +
          EFBIG: File too large
 +
  EHOSTUNREACH: No route to host
 +
          EIDRM: Identifier removed
 +
        EILSEQ: Invalid or incomplete multibyte or wide character
 +
    EINPROGRESS: Operation now in progress
 +
          EINTR: Interrupted system call
 +
        EINVAL: Invalid argument
 +
            EIO: Input/output error
 +
        EISCONN: Transport endpoint is already connected
 +
        EISDIR: Is a directory
 +
          ELOOP: Too many levels of symbolic links
 +
        EMFILE: Too many open files
 +
        EMLINK: Too many links
 +
      EMSGSIZE: Message too long
 +
  ENAMETOOLONG: File name too long
 +
      ENETDOWN: Network is down
 +
      ENETRESET: Network dropped connection on reset
 +
    ENETUNREACH: Network is unreachable
 +
        ENFILE: Too many open files in system
 +
        ENOBUFS: No buffer space available
 +
        ENODATA: No data available
 +
        ENODEV: No such device
 +
        ENOENT: No such file or directory
 +
        ENOEXEC: Exec format error
 +
        ENOLCK: No locks available
 +
        ENOLINK: Link has been severed
 +
        ENOMEM: Cannot allocate memory
 +
        ENOMSG: No message of desired type
 +
    ENOPROTOOPT: Protocol not available
 +
        ENOSPC: No space left on device
 +
          ENOSR: Out of streams resources
 +
        ENOSTR: Device not a stream
 +
        ENOSYS: Function not implemented
 +
      ENOTCONN: Transport endpoint is not connected
 +
        ENOTDIR: Not a directory
 +
      ENOTEMPTY: Directory not empty
 +
ENOTRECOVERABLE: State not recoverable
 +
      ENOTSOCK: Socket operation on non-socket
 +
        ENOTSUP: Operation not supported
 +
        ENOTTY: Inappropriate ioctl for device
 +
          ENXIO: No such device or address
 +
    EOPNOTSUPP: Operation not supported
 +
      EOVERFLOW: Value too large for defined data type
 +
    EOWNERDEAD: Owner died
 +
          EPERM: Operation not permitted
 +
          EPIPE: Broken pipe
 +
        EPROTO: Protocol error
 +
EPROTONOSUPPORT: Protocol not supported
 +
    EPROTOTYPE: Protocol wrong type for socket
 +
        ERANGE: Numerical result out of range
 +
          EROFS: Read-only file system
 +
        ESPIPE: Illegal seek
 +
          ESRCH: No such process
 +
          ETIME: Timer expired
 +
      ETIMEDOUT: Connection timed out
 +
        ETXTBSY: Text file busy
 +
    EWOULDBLOCK: Resource temporarily unavailable
 +
          EXDEV: Invalid cross-device link
 +
}}
  
 
===See also===
 
===See also===
{{dcl list begin}}
+
{{dsc begin}}
{{dcl list class  | cpp/error/system_error/err_c | the {{cpp|std::error_condition}} enumeration listing all standard {{tt|<cerrno>}} macro constants| notes={{mark c++11}}}}
+
{{dsc inc|cpp/error/dsc errc}}
{{dcl list macro const | cpp/error/errno | macro which expands to POSIX-compatible thread-local error number variable}}
+
{{dsc inc|cpp/error/dsc errno}}
{{dcl list template | cpp/io/c/dcl list perror}}
+
{{dsc inc|cpp/io/c/dsc perror}}
{{dcl list template | cpp/string/byte/dcl list strerror}}
+
{{dsc inc|cpp/string/byte/dsc strerror}}
{{dcl list end}}
+
{{dsc see c|c/error/errno_macros|Error numbers|nomono=true}}
 +
{{dsc end}}
 +
 
 +
{{langlinks|de|es|fr|it|ja|pt|ru|zh}}

Latest revision as of 11:21, 25 August 2023

 
 
 

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

#include <cerrno>
#include <cstring>
#include <iomanip>
#include <iostream>
 
#define SHOW(x) std::cout << std::setw(15) << #x << ": " << std::strerror(x) << '\n'
 
int main()
{
    std::cout << "Known error codes/messages:\n\n";
 
    SHOW( E2BIG );
    SHOW( EACCES );
    SHOW( EADDRINUSE );
    SHOW( EADDRNOTAVAIL );
    SHOW( EAFNOSUPPORT );
    SHOW( EAGAIN );
    SHOW( EALREADY );
    SHOW( EBADF );
    SHOW( EBADMSG );
    SHOW( EBUSY );
    SHOW( ECANCELED );
    SHOW( ECHILD );
    SHOW( ECONNABORTED );
    SHOW( ECONNREFUSED );
    SHOW( ECONNRESET );
    SHOW( EDEADLK );
    SHOW( EDESTADDRREQ );
    SHOW( EDOM );
    SHOW( EEXIST );
    SHOW( EFAULT );
    SHOW( EFBIG );
    SHOW( EHOSTUNREACH );
    SHOW( EIDRM );
    SHOW( EILSEQ );
    SHOW( EINPROGRESS );
    SHOW( EINTR );
    SHOW( EINVAL );
    SHOW( EIO );
    SHOW( EISCONN );
    SHOW( EISDIR );
    SHOW( ELOOP );
    SHOW( EMFILE );
    SHOW( EMLINK );
    SHOW( EMSGSIZE );
    SHOW( ENAMETOOLONG );
    SHOW( ENETDOWN );
    SHOW( ENETRESET );
    SHOW( ENETUNREACH );
    SHOW( ENFILE );
    SHOW( ENOBUFS );
    SHOW( ENODATA );
    SHOW( ENODEV );
    SHOW( ENOENT );
    SHOW( ENOEXEC );
    SHOW( ENOLCK );
    SHOW( ENOLINK );
    SHOW( ENOMEM );
    SHOW( ENOMSG );
    SHOW( ENOPROTOOPT );
    SHOW( ENOSPC );
    SHOW( ENOSR );
    SHOW( ENOSTR );
    SHOW( ENOSYS );
    SHOW( ENOTCONN );
    SHOW( ENOTDIR );
    SHOW( ENOTEMPTY );
    SHOW( ENOTRECOVERABLE );
    SHOW( ENOTSOCK );
    SHOW( ENOTSUP );
    SHOW( ENOTTY );
    SHOW( ENXIO );
    SHOW( EOPNOTSUPP );
    SHOW( EOVERFLOW );
    SHOW( EOWNERDEAD );
    SHOW( EPERM );
    SHOW( EPIPE );
    SHOW( EPROTO );
    SHOW( EPROTONOSUPPORT );
    SHOW( EPROTOTYPE );
    SHOW( ERANGE );
    SHOW( EROFS );
    SHOW( ESPIPE );
    SHOW( ESRCH );
    SHOW( ETIME );
    SHOW( ETIMEDOUT );
    SHOW( ETXTBSY );
    SHOW( EWOULDBLOCK );
    SHOW( EXDEV );
}

Possible output:

Known error codes/messages:
 
          E2BIG: Argument list too long
         EACCES: Permission denied
     EADDRINUSE: Address already in use
  EADDRNOTAVAIL: Cannot assign requested address
   EAFNOSUPPORT: Address family not supported by protocol
         EAGAIN: Resource temporarily unavailable
       EALREADY: Operation already in progress
          EBADF: Bad file descriptor
        EBADMSG: Bad message
          EBUSY: Device or resource busy
      ECANCELED: Operation canceled
         ECHILD: No child processes
   ECONNABORTED: Software caused connection abort
   ECONNREFUSED: Connection refused
     ECONNRESET: Connection reset by peer
        EDEADLK: Resource deadlock avoided
   EDESTADDRREQ: Destination address required
           EDOM: Numerical argument out of domain
         EEXIST: File exists
         EFAULT: Bad address
          EFBIG: File too large
   EHOSTUNREACH: No route to host
          EIDRM: Identifier removed
         EILSEQ: Invalid or incomplete multibyte or wide character
    EINPROGRESS: Operation now in progress
          EINTR: Interrupted system call
         EINVAL: Invalid argument
            EIO: Input/output error
        EISCONN: Transport endpoint is already connected
         EISDIR: Is a directory
          ELOOP: Too many levels of symbolic links
         EMFILE: Too many open files
         EMLINK: Too many links
       EMSGSIZE: Message too long
   ENAMETOOLONG: File name too long
       ENETDOWN: Network is down
      ENETRESET: Network dropped connection on reset
    ENETUNREACH: Network is unreachable
         ENFILE: Too many open files in system
        ENOBUFS: No buffer space available
        ENODATA: No data available
         ENODEV: No such device
         ENOENT: No such file or directory
        ENOEXEC: Exec format error
         ENOLCK: No locks available
        ENOLINK: Link has been severed
         ENOMEM: Cannot allocate memory
         ENOMSG: No message of desired type
    ENOPROTOOPT: Protocol not available
         ENOSPC: No space left on device
          ENOSR: Out of streams resources
         ENOSTR: Device not a stream
         ENOSYS: Function not implemented
       ENOTCONN: Transport endpoint is not connected
        ENOTDIR: Not a directory
      ENOTEMPTY: Directory not empty
ENOTRECOVERABLE: State not recoverable
       ENOTSOCK: Socket operation on non-socket
        ENOTSUP: Operation not supported
         ENOTTY: Inappropriate ioctl for device
          ENXIO: No such device or address
     EOPNOTSUPP: Operation not supported
      EOVERFLOW: Value too large for defined data type
     EOWNERDEAD: Owner died
          EPERM: Operation not permitted
          EPIPE: Broken pipe
         EPROTO: Protocol error
EPROTONOSUPPORT: Protocol not supported
     EPROTOTYPE: Protocol wrong type for socket
         ERANGE: Numerical result out of range
          EROFS: Read-only file system
         ESPIPE: Illegal seek
          ESRCH: No such process
          ETIME: Timer expired
      ETIMEDOUT: Connection timed out
        ETXTBSY: Text file busy
    EWOULDBLOCK: Resource temporarily unavailable
          EXDEV: Invalid cross-device link

[edit] 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