tihmstar / futurerestore

A hacked up idevicerestore wrapper, which allows specifying SEP and Baseband for restoring
GNU Lesser General Public License v3.0
865 stars 272 forks source link

Fix incorrect language standard #302

Open 0x9fff00 opened 4 years ago

0x9fff00 commented 4 years ago

This project uses POSIX extensions, which causes at least the following warnings and errors when compiling with -std=c11 and -std=c++11 (using GCC 9.2.0 on Arch Linux) since they don't support these extensions:

ipsw.c: In function ‘ipsw_open’:
ipsw.c:85:18: warning: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]
   85 |  archive->path = strdup(ipsw);
      |                  ^~~~~~
      |                  strcmp
ipsw.c:85:16: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   85 |  archive->path = strdup(ipsw);
      |                ^
ipsw.c: In function ‘ipsw_extract_to_file_with_progress’:
ipsw.c:227:24: error: ‘PATH_MAX’ undeclared (first use in this function)
  227 |   char actual_filepath[PATH_MAX+1];
      |                        ^~~~~~~~
ipsw.c:227:24: note: each undeclared identifier is reported only once for each function it appears in
ipsw.c:229:8: warning: implicit declaration of function ‘realpath’ [-Wimplicit-function-declaration]
  229 |   if (!realpath(filepath, actual_filepath)) {
      |        ^~~~~~~~
ipsw.c:249:15: warning: implicit declaration of function ‘fileno’ [-Wimplicit-function-declaration]
  249 |     if (fstat(fileno(fi), &fst) != 0) {
      |               ^~~~~~
ipsw.c: In function ‘ipsw_download_fw’:
ipsw.c:773:13: warning: assignment to ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
  773 |   *ipswfile = strdup(fwlfn);
      |             ^

To fix this, switch to -std=gnu11 and -std=gnu++11.

0x9fff00 commented 4 years ago

More specifically, the included idevicerestore uses POSIX extensions, and it doesn't define a standard, so it uses the standard defined by this which is incompatible.

Merculous commented 4 years ago

Can vouch, this fixed the missing headers issue I kept having.