From 6ad7a7486c3f1e1b907dadd132364fa9e611ccf0 Mon Sep 17 00:00:00 2001 From: Jim DeLaHunt Date: Sat, 29 Jan 2022 01:28:13 -0800 Subject: [PATCH] Eliminate needless -Wimplicit-function-declaration errors on macOS Configuration macros FC_CHECK_X_PROTO_FUNCPROTO_COMPILE and FC_CHECK_X_PROTO_NARROWPROTO_WORKS in m4/x.m4 generate simple C programs to check aspects of X11 configuration. These programs fail to #include , so their use of exit() is implicitly declared. This has been illegal C language since the late 1980's, but tolerated by compilers. However, since 2019, macOS compilers have raised -Wimplicit-function-declaration errors with such constructs. They have good reasons to do so, related to support for ARM instruction sets. Insert `#include ` into each of these two macros in m4/x.m4 . Similarly, configuration macro FC_FUNC_VSNPRINTF in m4/vsnprintf.m4 generates a simple C program which uses exit() without #include , and strcmp() without #include . This also causes the macOS compiler to raise -Wimplicit-function-declaration errors. Insert `#include ` and `#include ` into this macro in m4/vsnprintf.m4 . Fixes ticket #43737, "Configure scripts give needless -Wimplicit-function-declaration errors on macOS", https://osdn.net/projects/freeciv/ticket/43737 for more information. --- m4/vsnprintf.m4 | 2 ++ m4/x.m4 | 2 ++ 2 files changed, 4 insertions(+) diff --git a/m4/vsnprintf.m4 b/m4/vsnprintf.m4 index 87641f7479..282172fae5 100644 --- a/m4/vsnprintf.m4 +++ b/m4/vsnprintf.m4 @@ -14,6 +14,8 @@ AC_DEFUN([FC_FUNC_VSNPRINTF], [ac_cv_func_working_vsnprintf], [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include #include +#include +#include int doit(char * s, ...) diff --git a/m4/x.m4 b/m4/x.m4 index 5309dfc04b..80ef46e61c 100644 --- a/m4/x.m4 +++ b/m4/x.m4 @@ -325,6 +325,7 @@ fc_x_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $X_CFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ $fc_x_compile +#include #include ]], [[ exit (0) @@ -374,6 +375,7 @@ CFLAGS="$CFLAGS $X_CFLAGS $X_LIBS $X_PRE_LIBS -lXaw -lXt -lX11 $X_EXTRA_LIBS" AC_RUN_IFELSE([AC_LANG_SOURCE([[ $fc_x_works $fc_x_compile +#include #include #include #include -- 2.35.0