extern int errno 是通过系统调用设置的,在错误事件中的某些库函数表明了什么发生了错误。
// The -*- C++ -*- forwarding header.
// Copyright (C) 1997-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file cerrno
* This is a Standard C++ Library file. You should @c \#include this file
* in your programs, rather than any of the @a *.h implementation files.
*
* This is the C++ version of the Standard C Library header @c errno.h,
* and its contents are (mostly) the same as that header, but are all
* contained in the namespace @c std (except for names which are defined
* as macros in C).
*/
//
// ISO C++ 14882: 19.3 Error numbers
//
#pragma GCC system_header
#include <bits/c++config.h>
#include <errno.h>
#ifndef _GLIBCXX_CERRNO
#define _GLIBCXX_CERRNO 1
// Adhere to section 17.4.1.2 clause 5 of ISO 14882:1998
#ifndef errno
#define errno errno
#endif
#endif
-
EPERM (1): 操作不允许。
-
ENOENT (2): 文件或目录不存在。
-
ESRCH (3): 没有找到进程。
-
EINTR (4): 系统调用被中断。
-
EIO (5): 输入/输出错误。
-
ENXIO (6): 没有这样的设备或地址。
-
E2BIG (7): 参数列表太长。
-
ENOEXEC (8): 可执行文件格式错误。
-
EBADF (9): 无效的文件描述符。
-
ECHILD (10): 没有子进程。
-
EAGAIN (11): 再试一次(临时性错误)。
-
ENOMEM (12): 内存不足。
-
EACCES (13): 权限被拒绝。
-
EFAULT (14): 坏地址。
-
ENOTBLK (15): 需要块设备操作。
-
EBUSY (16): 设备或资源忙。
-
EEXIST (17): 文件已存在。
-
EXDEV (18): 跨设备链接。
-
ENODEV (19): 没有这样的设备。
-
ENOTDIR (20): 不是一个目录。
-
EISDIR (21): 是一个目录。
-
EINVAL (22): 无效的参数。
-
ENFILE (23): 文件表溢出。
-
EMFILE (24): 打开的文件太多。
-
ENOTTY (25): 不是终端或面向终端的操作。
-
ETXTBSY (26): 文本文件忙。
-
EFBIG (27): 文件太大,无法打开。
-
ENOSPC (28): 设备上没有空间。
-
ESPIPE (29): 非法的查找(seek)操作。
-
EROFS (30): 只读文件系统。
-
EMLINK (31): 太多硬链接。
-
EPIPE (32): 管道被破坏。
902

被折叠的 条评论
为什么被折叠?



