From b604640950b4f9bdcf035713f67f78a02e25d334 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sun, 23 Jul 2023 17:13:17 +0300 Subject: [PATCH] LibC: Fix struct declaration visibility Isn't "expected struct timeval *, but argument is of type struct timeval *" a fun error message? C considers a 'struct foo' mentioned inside a function argument to be a distinct type from 'struct foo' declared on the global level, but only if the in-function definition comes first. So we need to ensure that struct timeval is declared (either fully, or forward-declared) before we declare select() and pselect(). This was taken care of by including , but https://github.com/SerenityOS/serenity/pull/20044 made it so that itself includes . So if the user's program includes (before possibly including ), then 's include of will turn into a no-op (since is already being included), yet there will not have been a struct timeval definition yet, and we'd get the fun error message. Fix this by including instead of --- Userland/Libraries/LibC/sys/select.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibC/sys/select.h b/Userland/Libraries/LibC/sys/select.h index f16307c56c4..029d0e2aa72 100644 --- a/Userland/Libraries/LibC/sys/select.h +++ b/Userland/Libraries/LibC/sys/select.h @@ -6,6 +6,10 @@ #pragma once +// Make sure we have the time type definitions. We include the kernel API +// header and not the LibC to avoid issues with circular includes. +#include + // Includes essentially mandated by POSIX: // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html #include @@ -14,7 +18,6 @@ #include #include #include -#include #include __BEGIN_DECLS