From 0924a2e881b55862723168238d6bbc53def90a06 Mon Sep 17 00:00:00 2001 From: Parth Patel Date: Fri, 18 Oct 2024 02:30:59 -0500 Subject: [PATCH] gmain: Include poll.h as early as possible On AIX, the system poll.h redefines the names of struct members, for example `#define events reqevents`. This means that accesses to GPollFD will fail to compile if poll.h was included after glib/gpoll.h. We can't simply add `#include ` in glib/gpoll.h, because that wouldn't work on platforms where poll.h doesn't exist, and GLib supports some platforms in that category. Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/3500 --- glib/gmain.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/glib/gmain.c b/glib/gmain.c index 9de145340..775b55c0a 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -48,6 +48,15 @@ #define G_MAIN_POLL_DEBUG #endif +/* We need to include this as early as possible, because on some + * platforms like AIX, redefines the names we use for + * GPollFD struct members. + * See https://gitlab.gnome.org/GNOME/glib/-/issues/3500 */ + +#ifdef HAVE_POLL_H +#include +#endif + #ifdef G_OS_UNIX #include "glib-unix.h" #include @@ -69,10 +78,6 @@ #include #include -#ifdef HAVE_POLL_H -#include -#endif - #ifdef HAVE_PIDFD #include #include