Skip to content

Commit

Permalink
Refactor #25, check for header availability
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
troglobit committed Jul 31, 2024
1 parent 8ea9a51 commit f8cc168
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AC_PROG_INSTALL

dnl - Configuration.
AC_HEADER_STDC
AC_CHECK_HEADERS([sys/socket.h])

dnl Check for uint[8,16,32]_t
AC_TYPE_UINT8_T
Expand Down
4 changes: 2 additions & 2 deletions src/netcalc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

#include <stdint.h>
#include <err.h> /* warnx() et al */
#ifdef __APPLE__
#include <sys/socket.h> /* Has to be included before net/if.h */
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> /* Before net/if.h on Darwin */
#endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h> /* u_long on NetBSD */
Expand Down

0 comments on commit f8cc168

Please sign in to comment.