Search code examples
cxcodelibarchive

Use of undeclared identifier 'ENOMEM'


i using "libarchive" for my xcode project but get bellow errors

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

Use of undeclared identifier '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'

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'

   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'

how i can fix this errors?

screenshot of error

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


Solution

  • ENONEM and ERANGE are macros that are defined in errno.h. As for errno, it is an integer variable set when some errors are occurred.

    Thus, to access those variables/defines you need to add #include <errno.h> in your file.

    For more documentation : man errno