gpt4 book ai didi

c - strerror 描述字符串

转载 作者:IT王子 更新时间:2023-10-29 00:41:34 26 4
gpt4 key购买 nike

C 函数strerror 返回错误描述字符串,详见here .示例字符串

No such file or directory

问题是这些字符串在哪里定义的?我查看了我的头文件,但没有看到任何东西。

最佳答案

包含错误消息的头文件名为 errmsg.h

00012 const char *const sys_errlist[] = {
00013 "Operation succeeded", /* 0 */
00014 "Invalid argument", /* EINVAL */
00015 "Bad memory address", /* EFAULT */
00016 "String too long", /* ENAMETOOLONG */
00017 "Out of memory", /* ENOMEM */
00018 "Input/output error", /* EIO */
00019 "No such file or directory", /* ENOENT */
00020 "Not a directory", /* ENOTDIR */
00021 "Is a directory", /* EISDIR */
00022 "File or object exists", /* EEXIST */
00023 "Cross-device link", /* EXDEV */
00024 "Try again later", /* EAGAIN */
00025 "Illegal seek", /* ESPIPE */
00026 "Unimplemented feature", /* EUNIMP */
00027 "Device not available", /* ENXIO */
00028 "No such device", /* ENODEV */
00029 "Device or resource busy", /* EBUSY */
00030 "Invalid/inappropriate ioctl",/* EIOCTL (ENOTTY in Unix) */
00031 "Directory not empty", /* ENOTEMPTY */
00032 "Result too large", /* ERANGE */
00033 "No space left on device", /* ENOSPC */
00034 "Too many open files", /* EMFILE */
00035 "Too many open files in system",/* ENFILE */
00036 "No such system call", /* ENOSYS */
00037 "File is not executable", /* ENOEXEC */
00038 "Argument list too long", /* E2BIG */
00039 "Bad file number", /* EBADF */
00040 };

如您所见,它取决于 libc 实现。但总体思路是相同的:一些数组包含从错误号到最大长度为 1024 字节的字符串的映射。

其他实现:

关于c - strerror 描述字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13521702/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com