Skip to content

Commit

Permalink
Guard more system headers by FMT_MODULE
Browse files Browse the repository at this point in the history
  • Loading branch information
yujincheng08 committed Jun 9, 2024
1 parent 2bf811b commit d0a29c9
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion include/fmt/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_ARGS_H_
#define FMT_ARGS_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <functional> // std::reference_wrapper
# include <memory> // std::unique_ptr
# include <vector>
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# include <string.h> // strlen
#endif

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
// <cstddef> is also included transitively from <type_traits>.
# include <cstddef> // std::byte
# include <type_traits> // std::enable_if
#else
#elif !defined(FMT_MODULE)
import std;
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/fmt/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_CHRONO_H_
#define FMT_CHRONO_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <algorithm>
# include <chrono>
# include <cmath> // std::isfinite
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <iterator> // std::back_inserter
#endif

Expand Down
13 changes: 8 additions & 5 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@
#ifndef FMT_FORMAT_INL_H_
#define FMT_FORMAT_INL_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <algorithm>
# include <cmath>
# include <exception>
#endif
#include <cerrno> // errno
#include <climits>

#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
# include <locale>
#ifndef FMT_MODULE
# include <cerrno> // errno
# include <climits>

# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
# include <locale>
# endif
#endif

#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)
Expand Down
6 changes: 3 additions & 3 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# define FMT_REMOVE_TRANSITIVE_INCLUDES
#endif

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <cmath> // std::signbit
# include <cstdint> // uint32_t
# include <cstring> // std::memcpy
Expand All @@ -57,14 +57,14 @@

// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && \
!defined(FMT_IMPORT_STD)
!defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <bit> // std::bit_cast
#endif

// libc++ supports string_view in pre-c++17.
#if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# ifndef FMT_IMPORT_STD
# if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <string_view>
# endif
# define FMT_USE_STRING_VIEW
Expand Down
14 changes: 8 additions & 6 deletions include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
#ifndef FMT_OS_H_
#define FMT_OS_H_

#include <cerrno>
#ifndef FMT_IMPORT_STD
# include <cstddef>
# include <cstdio>
# include <system_error> // std::system_error
#ifndef FMT_MODULE
# include <cerrno>
# ifndef FMT_IMPORT_STD
# include <cstddef>
# include <cstdio>
# include <system_error> // std::system_error
# endif
#endif

#include "format.h"

#if defined __APPLE__ || defined(__FreeBSD__)
# if FMT_HAS_INCLUDE(<xlocale.h>)
# if FMT_HAS_INCLUDE(<xlocale.h>) && !defined(FMT_MODULE)
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X
# endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <fstream> // std::filebuf
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_PRINTF_H_
#define FMT_PRINTF_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <algorithm> // std::max
# include <limits> // std::numeric_limits
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_RANGES_H_
#define FMT_RANGES_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <initializer_list>
# include <iterator>
# include <tuple>
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef FMT_STD_H_
#define FMT_STD_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <atomic>
# include <bitset>
# include <complex>
Expand All @@ -29,7 +29,7 @@
# include <version>
#endif

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
# if FMT_CPLUSPLUS >= 201703L
# if FMT_HAS_INCLUDE(<filesystem>)
Expand Down
5 changes: 3 additions & 2 deletions include/fmt/xchar.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
#ifndef FMT_XCHAR_H_
#define FMT_XCHAR_H_

#ifndef FMT_IMPORT_STD
#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# include <cwchar>
#endif

#include "color.h"
#include "format.h"
#include "ranges.h"

#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) && \
!defined(FMT_MODULE)
# include <locale>
#endif

Expand Down
1 change: 1 addition & 0 deletions src/fmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module;
// to prevent attachment to this module.
#ifndef FMT_IMPORT_STD
# include <algorithm>
# include <bitset>
# include <chrono>
# include <cmath>
# include <complex>
Expand Down

0 comments on commit d0a29c9

Please sign in to comment.