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

@@ -3,12 +3,9 @@
#ifndef RGBDS_MAIN_H
#define RGBDS_MAIN_H
#include <stdint.h>
#include <stdio.h>
#include <string>
#include "helpers.hpp"
extern bool haltNop;
extern bool warnOnHaltNop;
extern bool optimizeLoads;

View File

@@ -3,8 +3,6 @@
#ifndef WARNING_H
#define WARNING_H
#include "helpers.hpp"
extern unsigned int nbErrors, maxErrors;
enum WarningState { WARNING_DEFAULT, WARNING_DISABLED, WARNING_ENABLED, WARNING_ERROR };

View File

@@ -3,8 +3,6 @@
#ifndef RGBDS_ERROR_H
#define RGBDS_ERROR_H
#include "platform.hpp"
extern "C" {
[[gnu::format(printf, 1, 2)]] void warn(char const *fmt...);

View File

@@ -3,9 +3,7 @@
#ifndef RGBDS_FILE_HPP
#define RGBDS_FILE_HPP
#include <array>
#include <assert.h>
#include <cassert>
#include <fcntl.h>
#include <fstream>
#include <ios>
@@ -13,10 +11,8 @@
#include <streambuf>
#include <string.h>
#include <string>
#include <string_view>
#include <variant>
#include "helpers.hpp"
#include "platform.hpp"
#include "gfx/main.hpp"

View File

@@ -4,15 +4,12 @@
#define RGBDS_GFX_MAIN_HPP
#include <array>
#include <limits.h>
#include <optional>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include "helpers.hpp"
#include "gfx/rgba.hpp"
struct Options {

View File

@@ -8,8 +8,6 @@
#include "defaultinitalloc.hpp"
#include "gfx/main.hpp"
struct Palette;
class ProtoPalette;

View File

@@ -4,7 +4,6 @@
#define RGBDS_GFX_PAL_SORTING_HPP
#include <array>
#include <assert.h>
#include <optional>
#include <png.h>
#include <vector>

View File

@@ -3,7 +3,6 @@
#ifndef RGBDS_GFX_PROTO_PALETTE_HPP
#define RGBDS_GFX_PROTO_PALETTE_HPP
#include <algorithm>
#include <array>
#include <stddef.h>
#include <stdint.h>

View File

@@ -9,7 +9,6 @@
#include <variant>
#include <vector>
#include "helpers.hpp"
#include "linkdefs.hpp"
// Variables related to CLI options

View File

@@ -3,8 +3,6 @@
#ifndef RGBDS_LINK_OUTPUT_H
#define RGBDS_LINK_OUTPUT_H
#include <stdint.h>
#include "link/section.hpp"
/*

View File

@@ -14,7 +14,6 @@
#include "linkdefs.hpp"
#include "link/main.hpp"
#include "link/patch.hpp"
struct FileStackNode;
struct Section;

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)

View File

@@ -2,7 +2,6 @@
#include "asm/charmap.hpp"
#include <errno.h>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
@@ -11,8 +10,6 @@
#include "util.hpp"
#include "asm/main.hpp"
#include "asm/output.hpp"
#include "asm/warning.hpp"
// Charmaps are stored using a structure known as "trie".

View File

@@ -6,9 +6,6 @@
#include <math.h>
#include "asm/symbol.hpp"
#include "asm/warning.hpp"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

View File

@@ -10,7 +10,6 @@
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string_view>
#include "error.hpp"
#include "helpers.hpp"

View File

@@ -12,7 +12,6 @@
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <new>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@@ -45,7 +45,6 @@
%code {
#include <algorithm>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -3,7 +3,6 @@
#include "asm/rpn.hpp"
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdio.h>
@@ -13,7 +12,6 @@
#include "opmath.hpp"
#include "asm/main.hpp"
#include "asm/output.hpp"
#include "asm/section.hpp"
#include "asm/symbol.hpp"

View File

@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <string.h>
#include "helpers.hpp"
#include "asm/fstack.hpp"
#include "asm/lexer.hpp"
#include "asm/main.hpp"

View File

@@ -3,13 +3,11 @@
#include "asm/symbol.hpp"
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdio.h>
#include <unordered_map>
#include "error.hpp"
#include "helpers.hpp"
#include "version.hpp"
#include "asm/fstack.hpp"

View File

@@ -5,7 +5,6 @@
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>

View File

@@ -5,11 +5,9 @@
#include <algorithm>
#include <assert.h>
#include <ctype.h>
#include <fstream>
#include <inttypes.h>
#include <ios>
#include <limits>
#include <numeric>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

View File

@@ -4,10 +4,8 @@
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <inttypes.h>
#include <numeric>
#include <optional>
#include <queue>
#include <type_traits>
@@ -15,6 +13,7 @@
#include "helpers.hpp"
#include "gfx/main.hpp"
#include "gfx/proto_palette.hpp"
using std::swap;

View File

@@ -3,11 +3,11 @@
#include "gfx/pal_sorting.hpp"
#include <algorithm>
#include <assert.h>
#include "helpers.hpp"
#include "gfx/main.hpp"
#include "gfx/process.hpp"
namespace sorting {

View File

@@ -9,7 +9,6 @@
#include <inttypes.h>
#include <limits.h>
#include <optional>
#include <ostream>
#include <stdint.h>
#include <stdio.h>
#include <streambuf>
@@ -17,9 +16,8 @@
#include <string>
#include <string_view>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include "helpers.hpp"
#include "platform.hpp"
#include "gfx/main.hpp"

View File

@@ -5,13 +5,9 @@
#include <algorithm>
#include <assert.h>
#include <errno.h>
#include <fstream>
#include <inttypes.h>
#include <limits.h>
#include <memory>
#include <optional>
#include <png.h>
#include <setjmp.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View File

@@ -2,6 +2,7 @@
#include "gfx/proto_palette.hpp"
#include <algorithm>
#include <assert.h>
#include "helpers.hpp"

View File

@@ -6,17 +6,14 @@
#include <array>
#include <assert.h>
#include <errno.h>
#include <fstream>
#include <inttypes.h>
#include <optional>
#include <png.h>
#include <string.h>
#include <tuple>
#include <vector>
#include "defaultinitalloc.hpp"
#include "file.hpp"
#include "helpers.hpp"
#include "itertools.hpp"
#include "gfx/main.hpp"

View File

@@ -2,7 +2,6 @@
#include "link/assign.hpp"
#include <algorithm>
#include <deque>
#include <inttypes.h>
#include <stdio.h>
@@ -14,9 +13,9 @@
#include "helpers.hpp"
#include "itertools.hpp"
#include "linkdefs.hpp"
#include "platform.hpp"
#include "link/main.hpp"
#include "link/object.hpp"
#include "link/output.hpp"
#include "link/section.hpp"
#include "link/symbol.hpp"

View File

@@ -2,7 +2,6 @@
#include "link/object.hpp"
#include <algorithm>
#include <deque>
#include <errno.h>
#include <inttypes.h>
@@ -17,11 +16,11 @@
#include "error.hpp"
#include "helpers.hpp"
#include "linkdefs.hpp"
#include "platform.hpp"
#include "version.hpp"
#include "link/assign.hpp"
#include "link/main.hpp"
#include "link/patch.hpp"
#include "link/sdas_obj.hpp"
#include "link/section.hpp"
#include "link/symbol.hpp"

View File

@@ -13,8 +13,9 @@
#include "error.hpp"
#include "extern/utf8decoder.hpp"
#include "itertools.hpp"
#include "helpers.hpp"
#include "linkdefs.hpp"
#include "platform.hpp"
#include "link/main.hpp"
#include "link/symbol.hpp"

View File

@@ -5,22 +5,15 @@
#include <assert.h>
#include <deque>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <variant>
#include <vector>
#include "error.hpp"
#include "helpers.hpp"
#include "opmath.hpp"
#include "platform.hpp"
#include "linkdefs.hpp"
#include "link/main.hpp"
#include "link/object.hpp"
#include "link/section.hpp"
#include "link/symbol.hpp"

View File

@@ -4,16 +4,13 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
#include <memory>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <tuple>
#include <variant>
#include "helpers.hpp"
#include "linkdefs.hpp"
#include "platform.hpp"

View File

@@ -9,6 +9,7 @@
#include <unordered_map>
#include "error.hpp"
#include "helpers.hpp"
std::vector<std::unique_ptr<Section>> sectionList;
std::unordered_map<std::string, size_t> sectionMap; // Indexes into `sectionList`

View File

@@ -2,15 +2,10 @@
#include "link/symbol.hpp"
#include <inttypes.h>
#include <stdlib.h>
#include <unordered_map>
#include "error.hpp"
#include "helpers.hpp"
#include "link/main.hpp"
#include "link/object.hpp"
#include "link/section.hpp"
std::unordered_map<std::string, Symbol *> symbols;

View File

@@ -2,8 +2,6 @@
#include "linkdefs.hpp"
#include "platform.hpp"
using namespace std::literals;
// The default values are the most lax, as they are used as-is by RGBASM; only RGBLINK has the full

View File

@@ -2,7 +2,6 @@
#include "version.hpp"
#include <stdio.h>
#include <string.h>
#include "helpers.hpp"

View File

@@ -22,7 +22,6 @@
#include <fcntl.h>
#include <fstream>
#include <limits>
#include <memory>
#include <png.h>
#include <stdarg.h>
#include <stdlib.h>