mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
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 <sys/time.h>, but https://github.com/SerenityOS/serenity/pull/20044 made it so that <sys/time.h> itself includes <sys/select.h>. So if the user's program includes <sys/time.h> (before possibly including <sys/select.h>), then <sys/select.h>'s include of <sys/time.h> will turn into a no-op (since <sys/time.h> 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 <Kernel/API/POSIX/sys/time.h> instead of <sys/time.h>
This commit is contained in:
parent
ddafc5dc98
commit
b604640950
Notes:
sideshowbarker
2024-07-17 01:11:48 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/b604640950 Pull-request: https://github.com/SerenityOS/serenity/pull/20158 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅ Reviewed-by: https://github.com/timschumi
1 changed files with 4 additions and 1 deletions
|
@ -6,6 +6,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// Make sure we have the time type definitions. We include the kernel API
|
||||
// header and not the LibC <sys/time.h> to avoid issues with circular includes.
|
||||
#include <Kernel/API/POSIX/sys/time.h>
|
||||
|
||||
// Includes essentially mandated by POSIX:
|
||||
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_select.h.html
|
||||
#include <signal.h>
|
||||
|
@ -14,7 +18,6 @@
|
|||
#include <fd_set.h>
|
||||
#include <string.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
|
Loading…
Reference in a new issue