futurerestore
futurerestore copied to clipboard
Fix incorrect language standard
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.
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.
Can vouch, this fixed the missing headers issue I kept having.