Clean up #includes

Remove unused headers, and avoid relying on transitive inclusions

`include-what-you-use` has been very useful for this!
This commit is contained in:
ISSOtm
2024-03-28 01:16:51 +01:00
parent cae7b5dcf6
commit e5078aba3b
38 changed files with 19 additions and 83 deletions

View File

@@ -7,11 +7,11 @@
// MSVC doesn't have str(n)casecmp, use a suitable replacement
#ifdef _MSC_VER
#include <string.h>
#include <string.h> // IWYU pragma: export
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#else
#include <strings.h>
#include <strings.h> // IWYU pragma: export
#endif
// MSVC prefixes the names of S_* macros with underscores,
@@ -24,21 +24,21 @@
// MSVC doesn't use POSIX types or defines for `read`
#ifdef _MSC_VER
#include <io.h>
#include <io.h> // IWYU pragma: export
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#define ssize_t int
#define SSIZE_MAX INT_MAX
#else
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>
#include <fcntl.h> // IWYU pragma: export
#include <limits.h> // IWYU pragma: export
#include <unistd.h> // IWYU pragma: export
#endif
// MSVC uses a different name for O_RDWR, and needs an additional _O_BINARY flag
#ifdef _MSC_VER
#include <fcntl.h>
#include <fcntl.h> // IWYU pragma: export
#define O_RDWR _O_RDWR
#define S_ISREG(field) ((field) & (_S_IFREG))
#define O_BINARY _O_BINARY
@@ -50,7 +50,7 @@
// Windows has stdin and stdout open as text by default, which we may not want
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <io.h>
#include <io.h> // IWYU pragma: export
#define setmode(fd, mode) _setmode(fd, mode)
#else
#define setmode(fd, mode) (0)