From 6231a1586da48a6e31a2143619d4b4bd8038d457 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Tue, 15 Oct 2024 15:49:11 -0700 Subject: [PATCH] kdtree: include alloca.h if the system has it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes build error on Solaris with gcc 14: ../libgweather/third-party/kdtree.c: In function ‘kd_insertf’: ../libgweather/third-party/kdtree.c:224:38: error: implicit declaration of function ‘alloca’ [-Wimplicit-function-declaration] 224 | bptr = buf = alloca(dim * sizeof *bptr); | ^~~~~~ Signed-off-by: Alan Coopersmith --- libgweather/meson.build | 4 ++++ libgweather/third-party/kdtree.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libgweather/meson.build b/libgweather/meson.build index 07f657b9..a32ae4c4 100644 --- a/libgweather/meson.build +++ b/libgweather/meson.build @@ -57,6 +57,10 @@ config_h.set_quoted('G_LOG_DOMAIN', 'GWeather') config_h.set_quoted('GWEATHER_BIN_LOCATION_DIR', pkglibdir) config_h.set_quoted('LIBGWEATHER_VERSION', meson.project_version()) +if c_compiler.has_header('alloca.h') + config_h.set('HAVE_ALLOCA_H', 1) +endif + if c_compiler.has_member('struct tm', 'tm_gmtoff', prefix: '#include ') config_h.set('HAVE_TM_TM_GMOFF', 1) endif diff --git a/libgweather/third-party/kdtree.c b/libgweather/third-party/kdtree.c index 6d329d8d..c54bf230 100644 --- a/libgweather/third-party/kdtree.c +++ b/libgweather/third-party/kdtree.c @@ -26,9 +26,7 @@ OF SUCH DAMAGE. */ /* single nearest neighbor search written by Tamas Nepusz */ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "config.h" #include #include @@ -36,6 +34,10 @@ OF SUCH DAMAGE. #include #include "kdtree.h" +#ifdef HAVE_ALLOCA_H +#include +#endif + #if defined(WIN32) || defined(__WIN32__) #include #endif -- GitLab