errno 常量errno Constants

语法Syntax


#include <errno.h>  

备注Remarks

errno 值是在出现各种错误条件时分配给 errno 的常量。The errno values are constants assigned to errno in the event of various error conditions.

ERRNO.H 包含 errno 值的定义。ERRNO.H contains the definitions of the errno values. 但是,并非 ERRNO.H 中给定的提供定义都可用于 32 位 Windows 操作系统。However, not all the definitions given in ERRNO.H are used in 32-bit Windows operating systems. ERRNO.H 中的某些值的存在是为了保持与 UNIX 系列操作系统的兼容性。Some of the values in ERRNO.H are present to maintain compatibility with the UNIX family of operating systems.

32 位 Windows 操作系统中的 errno 值是 XENIX 系统中的 errno 值的子集。The errno values in a 32-bit Windows operating system are a subset of the values for errno in XENIX systems. 因此,errno 值不一定与由从 Windows 操作系统进行的系统调用返回的实际错误代码相同。Thus, the errno value is not necessarily the same as the actual error code returned by a system call from the Windows operating systems. 若要访问实际操作系统错误代码,请使用包含此值的 _doserrno 变量。To access the actual operating system error code, use the _doserrno variable, which contains this value.

下列 errno 值受支持:The following errno values are supported:

ECHILDECHILD
没有生成的进程。No spawned processes.

EAGAINEAGAIN
没有其他进程。No more processes. 尝试创建新进程失败,原因是没有更多的进程槽、没有足够的内存或者已到达最大嵌套级别。An attempt to create a new process failed because there are no more process slots, or there is not enough memory, or the maximum nesting level has been reached.

E2BIGE2BIG
自变量列表太长。Argument list too long.

EACCESEACCES
权限被拒绝。Permission denied. 文件的权限设置不允许指定的访问权限。The file's permission setting does not allow the specified access. 此错误表示尝试通过与某个文件的特性不兼容的方式访问该文件(或者,在某些情况下为目录)。This error signifies that an attempt was made to access a file (or, in some cases, a directory) in a way that is incompatible with the file's attributes.

例如,当尝试从未打开的文件读取、打开现有的只读文件进行写入或打开目录而不是文件时,将会发生错误。For example, the error can occur when an attempt is made to read from a file that is not open, to open an existing read-only file for writing, or to open a directory instead of a file. 在 MS-DOS 操作系统版本 3.0 以及更高版本下,EACCES 也可能表示锁定或共享冲突。Under MS-DOS operating system versions 3.0 and later, EACCES may also indicate a locking or sharing violation.

在尝试重命名文件或目录或者删除现有目录时也可能发生错误。The error can also occur in an attempt to rename a file or directory or to remove an existing directory.

EBADFEBADF
文件编号错误。Bad file number. 可能有两种原因:1) 指定的文件描述符不是有效值,或者未引用打开的文件。There are two possible causes: 1) The specified file descriptor is not a valid value or does not refer to an open file. 2) 尝试写入到已打开进行只读访问的文件或设备。2) An attempt was made to write to a file or device opened for read-only access.

EDEADLOCKEDEADLOCK
将会发生资源死锁。Resource deadlock would occur. 数学函数的自变量未在函数域中。The argument to a math function is not in the domain of the function.

EDOMEDOM
数学自变量。Math argument.

EEXISTEEXIST
文件存在。Files exist. 尝试创建已存在的文件。An attempt has been made to create a file that already exists. 例如,在 _open 调用中指定 _O_CREAT 和 _O_EXCL 标志,但命名的文件已存在。For example, the _O_CREAT and _O_EXCL flags are specified in an _open call, but the named file already exists.

EILSEQEILSEQ
非法字节序列(例如,在 MBCS 字符串中)。Illegal sequence of bytes (for example, in an MBCS string).

EINVALEINVAL
无效的参数。Invalid argument. 为某个函数的自变量之一给定了无效值。An invalid value was given for one of the arguments to a function. 例如,在定位文件指针时为原始位置给定的值(通过调用 fseek)位于文件头的前面。For example, the value given for the origin when positioning a file pointer (by means of a call to fseek) is before the beginning of the file.

EMFILEEMFILE
打开的文件太多。Too many open files. 没有更多文件说明符可用,因此无法打开更多文件。No more file descriptors are available, so no more files can be opened.

ENOENTENOENT
没有此文件或目录。No such file or directory. 指定的文件或目录不存在或无法找到。The specified file or directory does not exist or cannot be found. 只要指定的文件不存在或路径的组件未指定现有的目录,就可能出现此消息。This message can occur whenever a specified file does not exist or a component of a path does not specify an existing directory.

ENOEXECENOEXEC
执行格式错误。Exec format error. 尝试执行不可执行的文件或具有无效的可执行文件格式的文件。An attempt was made to execute a file that is not executable or that has an invalid executable-file format.

ENOMEMENOMEM
内核不够。Not enough core. 无法为尝试的运算符提供足够的内存。Not enough memory is available for the attempted operator. 例如,当可用于执行子进程的内存不足时,或者当无法满足 _getcwd 调用中的分配请求时,就会出现此消息。For example, this message can occur when insufficient memory is available to execute a child process, or when the allocation request in a _getcwd call cannot be satisfied.

ENOSPCENOSPC
设备上没有剩余空间。No space left on device. 设备上没有可供写入的其他空间(例如,当磁盘已满时)。No more space for writing is available on the device (for example, when the disk is full).

ERANGEERANGE
结果太大。Result too large. 数学函数的自变量太大,造成结果中的有效位部分或全部丢失。An argument to a math function is too large, resulting in partial or total loss of significance in the result. 当参数大于预期值时(例如,当 _getcwd 的 buffer 参数大于预期值时),在其他函数中也可能发生此错误。This error can also occur in other functions when an argument is larger than expected (for example, when the buffer argument to _getcwd is longer than expected).

EXDEVEXDEV
跨设备链接。Cross-device link. 尝试将文件移至不同的设备(使用 rename 函数)。An attempt was made to move a file to a different device (using the rename function).

STRUNCATESTRUNCATE
字符串复制或串联导致字符串被截断。A string copy or concatenation resulted in a truncated string. 请参阅 _TRUNCATESee _TRUNCATE.

下列值支持 Posix 的兼容性。The following values are supported for compatibility with Posix. 它们都是非 Posix 系统上必需的值。They are required values on non-Posix systems.

#define E2BIG [argument list too long]  
#define EACCES [permission denied]  
#define EADDRINUSE [address in use]  
#define EADDRNOTAVAIL [address not available]  
#define EAFNOSUPPORT [address family not supported]  
#define EAGAIN [resource unavailable try again]  
#define EALREADY [connection already in progress]  
#define EBADF [bad file descriptor]  
#define EBADMSG [bad message]  
#define EBUSY [device or resource busy]  
#define ECANCELED [operation canceled]  
#define ECHILD [no child process]  
#define ECONNABORTED [connection aborted]  
#define ECONNREFUSED [connection refused]  
#define ECONNRESET [connection reset]  
#define EDEADLK [resource deadlock would occur]  
#define EDESTADDRREQ [destination address required]  
#define EDOM [argument out of domain]  
#define EEXIST [file exists]  
#define EFAULT [bad address]  
#define EFBIG [file too large]  
#define EHOSTUNREACH [host unreachable]  
#define EIDRM [identifier removed]  
#define EILSEQ [illegal byte sequence]  
#define EINPROGRESS [operation in progress]  
#define EINTR [interrupted]  
#define EINVAL [invalid argument]  
#define EIO [io error]  
#define EISCONN [already connected]  
#define EISDIR [is a directory]  
#define ELOOP [too many synbolic link levels]  
#define EMFILE [too many files open]  
#define EMLINK [too many links]  
#define EMSGSIZE [message size]  
#define ENAMETOOLONG [filename too long]  
#define ENETDOWN [network down]  
#define ENETRESET [network reset]  
#define ENETUNREACH [network unreachable]  
#define ENFILE [too many files open in system]  
#define ENOBUFS [no buffer space]  
#define ENODATA [no message available]  
#define ENODEV [no such device]  
#define ENOENT [no such file or directory]  
#define ENOEXEC [executable format error]  
#define ENOLCK [no lock available]  
#define ENOLINK [no link]  
#define ENOMEM [not enough memory]  
#define ENOMSG [no message]  
#define ENOPROTOOPT [no protocol option]  
#define ENOSPC [no space on device]  
#define ENOSR [no stream resources]  
#define ENOSTR [not a stream]  
#define ENOSYS [function not supported]  
#define ENOTCONN [not connected]  
#define ENOTDIR [not a directory]  
#define ENOTEMPTY [directory not empty]  
#define ENOTRECOVERABLE [state not recoverable]  
#define ENOTSOCK [not a socket]  
#define ENOTSUP [not supported]  
#define ENOTTY [inappropriate io control operation]  
#define ENXIO [no such device or address]  
#define EOPNOTSUPP [operation not supported]  
#define EOTHER [other]  
#define EOVERFLOW [value too large]  
#define EOWNERDEAD [owner dead]  
#define EPERM [operation not permitted]  
#define EPIPE [broken pipe]  
#define EPROTO [protocol error]  
#define EPROTONOSUPPORT [protocol not supported]  
#define EPROTOTYPE [wrong protocol type]  
#define ERANGE [result out of range]  
#define EROFS [read only file system]  
#define ESPIPE [invalid seek]  
#define ESRCH [no such process]  
#define ETIME [stream timeout]  
#define ETIMEDOUT [timed out]  
#define ETXTBSY [text file busy]  
#define EWOULDBLOCK [operation would block]  
#define EXDEV [cross device link]  

另请参阅See Also

全局常量Global Constants