简体   繁体   English

使用未声明的标识符“ ENOMEM”

[英]Use of undeclared identifier 'ENOMEM'

i using "libarchive" for my xcode project but get bellow errors 我为我的xcode项目使用“ libarchive”,但出现以下错误

if (bytes_read < mine->block_size && ferror(mine->f)) {
    archive_set_error(a, errno, "Error reading file");
}

Use of undeclared identifier 'errno' 使用未声明的标识符“ errno”

if (mine == NULL || b == NULL) {
    archive_set_error(a, ENOMEM, "No memory");
    free(mine);
    free(b);
    return (ARCHIVE_FATAL);
}

Use of undeclared identifier 'ENOMEM' 使用未声明的标识符“ ENOMEM”

if (format_number(archive_entry_uid(entry), h + USTAR_uid_offset, USTAR_uid_size, USTAR_uid_max_size, strict)) {
    archive_set_error(&a->archive, ERANGE, "Numeric user ID too large");
    ret = ARCHIVE_FAILED;
}

Use of undeclared identifier 'ERANGE' 使用未声明的标识符“ ERANGE”

   write_nulls(struct archive_write *a, size_t padding)
{
  int ret;
  size_t to_write;

   while (padding > 0) {
    to_write = padding < a->null_length ? padding : a->null_length;
    ret = (a->compressor.write)(a, a->nulls, to_write);
    if (ret != ARCHIVE_OK)
    return (ret);
    padding -= to_write;
}
return (ARCHIVE_OK);}

No member named 'compressor' in 'struct archive_write' 在'struct archive_write'中没有名为'compressor'的成员

how i can fix this errors? 我该如何解决此错误?

错误的屏幕截图

https://github.com/Tarsnap/tarsnap/blob/master/libarchive/archive_write_set_format_ustar.c https://github.com/Tarsnap/tarsnap/blob/master/libarchive/archive_write_set_format_ustar.c

ENONEM and ERANGE are macros that are defined in errno.h . ENONEMERANGE是在errno.h中定义的errno.h As for errno , it is an integer variable set when some errors are occurred. 至于errno ,它是发生某些错误时设置的整数变量。

Thus, to access those variables/defines you need to add #include <errno.h> in your file. 因此,要访问这些变量/定义,您需要在文件中添加#include <errno.h>

For more documentation : man errno 有关更多文档: man errno

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM