sahlberg / libnfs

NFS client library
Other
510 stars 200 forks source link

Build error on macOS: `error: 'IFNAMSIZ' undeclared here (not in a function)` etc. #455

Closed barracuda156 closed 5 months ago

barracuda156 commented 5 months ago

With modern GCC there are a lot of these buf-related warnings, which eventually turn into error:

/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/nfs/libnfs-raw-nfs.c: In function 'zdr_MKDIR2resok':
make[2]: *** [mount/CMakeFiles/nfs_mount.dir/mount.c.o] Error 1/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/nfs/libnfs-raw-nfs.c:2877:27: warning: variable 'buf' set but not used [-Wunused-but-set-variable]
 2877 |         register int32_t *buf;
      |                           ^~~

. . .
In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/portmap/portmap.c:25:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/include/libnfs-private.h:178:21: error: 'IFNAMSIZ' undeclared here (not in a function)
  178 |         char ifname[IFNAMSIZ];
      |                     ^~~~~~~~
. . .

Old gcc-4.2 is more forgiving, but it fails on the second issue:

In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/nsm/nsm.c:27:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/include/libnfs-private.h:178: error: ‘IFNAMSIZ’ undeclared here (not in a function)
In file included from /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/nlm/nlm.c:27:
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_libnfs/libnfs/work/libnfs-5.0.3/include/libnfs-private.h:178: error: ‘IFNAMSIZ’ undeclared here (not in a function)
make[2]: *** [nsm/CMakeFiles/nfs_nsm.dir/nsm.c.o] Error 1
sahlberg commented 5 months ago

The first ones are from machine-generated files, produced by old old rpcgen, so that is what it is.

The second one comes from net/if.h which should be part of OSX. I don't have access to OSX so can not tell what the issue is, is net/if.h missing on OSX? Is the OSX net/if.h missing IFNAMSIZ? Are we not including net/if.h on OSX for some reason?

Pull request for OSX appreciated.

barracuda156 commented 5 months ago

@sahlberg Ah, I may know what is causing the error. Let me try a fix.