Skip to content

Commit

Permalink
Apply some fixes suggested by IWYU, suppress others
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Jun 19, 2024
1 parent 9b10c10 commit d654145
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
17 changes: 12 additions & 5 deletions kaitai/kaitaistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@
#include <stdint.h> // int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t

#include <algorithm> // std::reverse
#include <cerrno> // errno, ERANGE
#include <cstddef> // std::size_t
#include <cstdlib> // std::strtoll
#include <cerrno> // errno, EINVAL, E2BIG, EILSEQ, ERANGE
#include <cstdlib> // std::size_t, std::strtoll
#include <cstring> // std::memcpy
#include <ios> // std::streamsize
#include <istream> // std::istream
#include <sstream> // std::stringstream, std::ostringstream
#include <istream> // std::istream // IWYU pragma: keep
#include <sstream> // std::stringstream, std::ostringstream // IWYU pragma: keep
#include <stdexcept> // std::runtime_error, std::invalid_argument, std::out_of_range
#include <string> // std::string, std::getline
#include <vector> // std::vector
Expand Down Expand Up @@ -589,6 +588,14 @@ std::string kaitai::kstream::process_rotate_left(std::string data, int amount) {
#ifdef KS_ZLIB
#include <zlib.h>

// This instructs include-what-you-use not to suggest `#include <zconf.h>` just because it contains
// the definition of `Bytef`. It seems `<zconf.h>` is not a header for public use or at least it's
// not considered necessary to include it on top of `<zlib.h>`, because official usage examples that
// use `Bytef` only include `<zlib.h>`, see
// https://github.com/madler/zlib/blob/0f51fb4933fc9ce18199cb2554dacea8033e7fd3/test/example.c#L71
//
// IWYU pragma: no_include <zconf.h>

std::string kaitai::kstream::process_zlib(std::string data) {
int ret;

Expand Down
5 changes: 2 additions & 3 deletions kaitai/kaitaistream.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

#include <stdint.h> // int8_t, int16_t, int32_t, int64_t, uint8_t, uint16_t, uint32_t, uint64_t

#include <ios> // std::streamsize
#include <istream> // std::istream
#include <ios> // std::streamsize, forward declaration of std::istream // IWYU pragma: keep
#include <limits> // std::numeric_limits
#include <sstream> // std::istringstream
#include <sstream> // std::istringstream // IWYU pragma: keep
#include <string> // std::string

#ifdef KAITAI_STREAM_H_CPP11_SUPPORT
Expand Down

0 comments on commit d654145

Please sign in to comment.