Guard more system headers by FMT_MODULE (#4006)

* Guard more system headers by `FMT_MODULE`

* Merge FMT_MODULE and FMT_IMPORT_STD
This commit is contained in:
LoveSy 2024-06-15 01:53:51 +08:00 committed by GitHub
parent 98dd673cf8
commit 8687315e86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 69 additions and 65 deletions

View File

@ -8,7 +8,7 @@
#ifndef FMT_ARGS_H_ #ifndef FMT_ARGS_H_
#define FMT_ARGS_H_ #define FMT_ARGS_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <functional> // std::reference_wrapper # include <functional> // std::reference_wrapper
# include <memory> // std::unique_ptr # include <memory> // std::unique_ptr
# include <vector> # include <vector>

View File

@ -8,19 +8,19 @@
#ifndef FMT_BASE_H_ #ifndef FMT_BASE_H_
#define FMT_BASE_H_ #define FMT_BASE_H_
#if defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
# define FMT_MODULE
#endif
// c headers are preferable for performance reasons // c headers are preferable for performance reasons
#ifndef FMT_MODULE #ifndef FMT_MODULE
# include <limits.h> // CHAR_BIT # include <limits.h> // CHAR_BIT
# include <stdio.h> // FILE # include <stdio.h> // FILE
# include <string.h> // strlen # include <string.h> // strlen
#endif
#ifndef FMT_IMPORT_STD
// <cstddef> is also included transitively from <type_traits>. // <cstddef> is also included transitively from <type_traits>.
# include <cstddef> // std::byte # include <cstddef> // std::byte
# include <type_traits> // std::enable_if # include <type_traits> // std::enable_if
#else
import std;
#endif #endif
// The fmt library version in the form major * 10000 + minor * 100 + patch. // The fmt library version in the form major * 10000 + minor * 100 + patch.

View File

@ -8,7 +8,7 @@
#ifndef FMT_CHRONO_H_ #ifndef FMT_CHRONO_H_
#define FMT_CHRONO_H_ #define FMT_CHRONO_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <algorithm> # include <algorithm>
# include <chrono> # include <chrono>
# include <cmath> // std::isfinite # include <cmath> // std::isfinite

View File

@ -8,7 +8,7 @@
#ifndef FMT_COMPILE_H_ #ifndef FMT_COMPILE_H_
#define FMT_COMPILE_H_ #define FMT_COMPILE_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <iterator> // std::back_inserter # include <iterator> // std::back_inserter
#endif #endif

View File

@ -8,16 +8,16 @@
#ifndef FMT_FORMAT_INL_H_ #ifndef FMT_FORMAT_INL_H_
#define FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <algorithm> # include <algorithm>
# include <cerrno> // errno
# include <climits>
# include <cmath> # include <cmath>
# include <exception> # include <exception>
#endif
#include <cerrno> // errno
#include <climits>
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) # if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
# include <locale> # include <locale>
# endif
#endif #endif
#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE) #if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)

View File

@ -38,7 +38,7 @@
# define FMT_REMOVE_TRANSITIVE_INCLUDES # define FMT_REMOVE_TRANSITIVE_INCLUDES
#endif #endif
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <cmath> // std::signbit # include <cmath> // std::signbit
# include <cstdint> // uint32_t # include <cstdint> // uint32_t
# include <cstring> // std::memcpy # include <cstring> // std::memcpy
@ -56,15 +56,14 @@
#include "base.h" #include "base.h"
// Checking FMT_CPLUSPLUS for warning suppression in MSVC. // Checking FMT_CPLUSPLUS for warning suppression in MSVC.
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && \ #if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && !defined(FMT_MODULE)
!defined(FMT_IMPORT_STD)
# include <bit> // std::bit_cast # include <bit> // std::bit_cast
#endif #endif
// libc++ supports string_view in pre-c++17. // libc++ supports string_view in pre-c++17.
#if FMT_HAS_INCLUDE(<string_view>) && \ #if FMT_HAS_INCLUDE(<string_view>) && \
(FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION))
# ifndef FMT_IMPORT_STD # if !defined(FMT_MODULE)
# include <string_view> # include <string_view>
# endif # endif
# define FMT_USE_STRING_VIEW # define FMT_USE_STRING_VIEW

View File

@ -8,8 +8,8 @@
#ifndef FMT_OS_H_ #ifndef FMT_OS_H_
#define FMT_OS_H_ #define FMT_OS_H_
#include <cerrno> #ifndef FMT_MODULE
#ifndef FMT_IMPORT_STD # include <cerrno>
# include <cstddef> # include <cstddef>
# include <cstdio> # include <cstdio>
# include <system_error> // std::system_error # include <system_error> // std::system_error
@ -18,7 +18,7 @@
#include "format.h" #include "format.h"
#if defined __APPLE__ || defined(__FreeBSD__) #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 # include <xlocale.h> // for LC_NUMERIC_MASK on OS X
# endif # endif
#endif #endif

View File

@ -8,7 +8,7 @@
#ifndef FMT_OSTREAM_H_ #ifndef FMT_OSTREAM_H_
#define FMT_OSTREAM_H_ #define FMT_OSTREAM_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <fstream> // std::filebuf # include <fstream> // std::filebuf
#endif #endif

View File

@ -8,7 +8,7 @@
#ifndef FMT_PRINTF_H_ #ifndef FMT_PRINTF_H_
#define FMT_PRINTF_H_ #define FMT_PRINTF_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <algorithm> // std::max # include <algorithm> // std::max
# include <limits> // std::numeric_limits # include <limits> // std::numeric_limits
#endif #endif

View File

@ -8,7 +8,7 @@
#ifndef FMT_RANGES_H_ #ifndef FMT_RANGES_H_
#define FMT_RANGES_H_ #define FMT_RANGES_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <initializer_list> # include <initializer_list>
# include <iterator> # include <iterator>
# include <string> # include <string>

View File

@ -8,7 +8,7 @@
#ifndef FMT_STD_H_ #ifndef FMT_STD_H_
#define FMT_STD_H_ #define FMT_STD_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <atomic> # include <atomic>
# include <bitset> # include <bitset>
# include <complex> # include <complex>
@ -29,7 +29,7 @@
# include <version> # include <version>
#endif #endif
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
// Checking FMT_CPLUSPLUS for warning suppression in MSVC. // Checking FMT_CPLUSPLUS for warning suppression in MSVC.
# if FMT_CPLUSPLUS >= 201703L # if FMT_CPLUSPLUS >= 201703L
# if FMT_HAS_INCLUDE(<filesystem>) # if FMT_HAS_INCLUDE(<filesystem>)

View File

@ -8,7 +8,7 @@
#ifndef FMT_XCHAR_H_ #ifndef FMT_XCHAR_H_
#define FMT_XCHAR_H_ #define FMT_XCHAR_H_
#ifndef FMT_IMPORT_STD #ifndef FMT_MODULE
# include <cwchar> # include <cwchar>
#endif #endif
@ -16,7 +16,7 @@
#include "format.h" #include "format.h"
#include "ranges.h" #include "ranges.h"
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_MODULE)
# include <locale> # include <locale>
#endif #endif

View File

@ -4,6 +4,7 @@ module;
// to prevent attachment to this module. // to prevent attachment to this module.
#ifndef FMT_IMPORT_STD #ifndef FMT_IMPORT_STD
# include <algorithm> # include <algorithm>
# include <bitset>
# include <chrono> # include <chrono>
# include <cmath> # include <cmath>
# include <complex> # include <complex>
@ -40,6 +41,8 @@ module;
# include <stdint.h> # include <stdint.h>
# include <stdio.h> # include <stdio.h>
# include <time.h> # include <time.h>
import std;
#endif #endif
#include <cerrno> #include <cerrno>
#include <climits> #include <climits>

View File

@ -12,47 +12,49 @@
#include "fmt/os.h" #include "fmt/os.h"
#include <climits> #ifndef FMT_MODULE
# include <climits>
#if FMT_USE_FCNTL # if FMT_USE_FCNTL
# include <sys/stat.h> # include <sys/stat.h>
# include <sys/types.h> # include <sys/types.h>
# ifdef _WRS_KERNEL // VxWorks7 kernel # ifdef _WRS_KERNEL // VxWorks7 kernel
# include <ioLib.h> // getpagesize # include <ioLib.h> // getpagesize
# endif
# ifndef _WIN32
# include <unistd.h>
# else
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <io.h>
# ifndef S_IRUSR
# define S_IRUSR _S_IREAD
# endif
# ifndef S_IWUSR
# define S_IWUSR _S_IWRITE
# endif
# ifndef S_IRGRP
# define S_IRGRP 0
# endif
# ifndef S_IWGRP
# define S_IWGRP 0
# endif
# ifndef S_IROTH
# define S_IROTH 0
# endif
# ifndef S_IWOTH
# define S_IWOTH 0
# endif
# endif // _WIN32
# endif // FMT_USE_FCNTL
# ifdef _WIN32
# include <windows.h>
# endif # endif
# ifndef _WIN32
# include <unistd.h>
# else
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <io.h>
# ifndef S_IRUSR
# define S_IRUSR _S_IREAD
# endif
# ifndef S_IWUSR
# define S_IWUSR _S_IWRITE
# endif
# ifndef S_IRGRP
# define S_IRGRP 0
# endif
# ifndef S_IWGRP
# define S_IWGRP 0
# endif
# ifndef S_IROTH
# define S_IROTH 0
# endif
# ifndef S_IWOTH
# define S_IWOTH 0
# endif
# endif // _WIN32
#endif // FMT_USE_FCNTL
#ifdef _WIN32
# include <windows.h>
#endif #endif
namespace { namespace {