Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netcalc.h: add missing include for macOS #25

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

barracuda156
Copy link

Fix for macOS: some versions require sys/socket.h be included before net/if.h, otherwise build breaks down.

@barracuda156
Copy link
Author

Without this fix on 10.6:

Making all in src
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/src'
  CC       netcalc-netcalc.o
  CC       netcalc-cprintf.o
  CC       netcalc-output.o
  CC       netcalc-misc.o
In file included from netcalc.h:35,
                 from output.c:35:
/usr/include/net/if.h:264: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:265: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:305: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:306: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:307: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:379: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:380: error: field ‘dstaddr’ has incomplete type
In file included from netcalc.h:35,
                 from netcalc.c:41:
/usr/include/net/if.h:264: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:265: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:305: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:306: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:307: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:379: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:380: error: field ‘dstaddr’ has incomplete type
make[2]: *** [netcalc-output.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [netcalc-netcalc.o] Error 1
In file included from netcalc.h:35,
                 from misc.c:36:
/usr/include/net/if.h:264: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:265: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:305: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:306: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:307: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:379: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:380: error: field ‘dstaddr’ has incomplete type
make[2]: *** [netcalc-misc.o] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/src'
make[1]: *** [all-recursive] Error 1

Once header added, it builds fine:

Making all in src
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/src'
  CC       netcalc-output.o
  CC       netcalc-netcalc.o
  CC       netcalc-misc.o
output.c: In function ‘show_network_ranges_v4’:
output.c:39: warning: ‘min’ may be used uninitialized in this function
output.c: In function ‘print_cf_info_v4’:
output.c:115: warning: ‘min’ may be used uninitialized in this function
output.c:115: warning: ‘max’ may be used uninitialized in this function
  CCLD     netcalc
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/src'
Making all in tests
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/tests'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6/tests'
make[2]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6'
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6'
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_net_netcalc/netcalc/work/netcalc-2.1.6'

@troglobit
Copy link
Owner

Nice work 👍

@troglobit troglobit merged commit e0d8c3c into troglobit:master Jul 26, 2024
3 checks passed
@barracuda156
Copy link
Author

Thanks for merging!

@barracuda156 barracuda156 deleted the apple branch July 26, 2024 09:18
troglobit added a commit that referenced this pull request Jul 31, 2024
Some older FreeBSD based systems seem to need this header too before
net/if.h, so let's use the recommended[1] way of checking instead of
hard-coding __APPLE__ (or __FreeBSD__).

[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/Header-Portability.html

Signed-off-by: Joachim Wiberg <[email protected]>
@troglobit
Copy link
Owner

Just released v2.1.7, with a slightly changed #ifdef for your PR to increase portability and usefulness on other (*BSD) systems.

@barracuda156
Copy link
Author

Updated in macports/macports-ports@565f5cf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants