mirror of
https://github.com/fmtlib/fmt.git
synced 2024-09-04 14:09:14 +00:00
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:
parent
98dd673cf8
commit
8687315e86
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_ARGS_H_
|
||||
#define FMT_ARGS_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <functional> // std::reference_wrapper
|
||||
# include <memory> // std::unique_ptr
|
||||
# include <vector>
|
||||
|
@ -8,19 +8,19 @@
|
||||
#ifndef 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
|
||||
#ifndef FMT_MODULE
|
||||
# include <limits.h> // CHAR_BIT
|
||||
# include <stdio.h> // FILE
|
||||
# include <string.h> // strlen
|
||||
#endif
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
// <cstddef> is also included transitively from <type_traits>.
|
||||
# include <cstddef> // std::byte
|
||||
# include <type_traits> // std::enable_if
|
||||
#else
|
||||
import std;
|
||||
#endif
|
||||
|
||||
// The fmt library version in the form major * 10000 + minor * 100 + patch.
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_CHRONO_H_
|
||||
#define FMT_CHRONO_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <algorithm>
|
||||
# include <chrono>
|
||||
# include <cmath> // std::isfinite
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_COMPILE_H_
|
||||
#define FMT_COMPILE_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <iterator> // std::back_inserter
|
||||
#endif
|
||||
|
||||
|
@ -8,16 +8,16 @@
|
||||
#ifndef FMT_FORMAT_INL_H_
|
||||
#define FMT_FORMAT_INL_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <algorithm>
|
||||
# include <cerrno> // errno
|
||||
# include <climits>
|
||||
# include <cmath>
|
||||
# include <exception>
|
||||
#endif
|
||||
#include <cerrno> // errno
|
||||
#include <climits>
|
||||
|
||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD)
|
||||
# include <locale>
|
||||
# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
# include <locale>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(FMT_USE_WRITE_CONSOLE)
|
||||
|
@ -38,7 +38,7 @@
|
||||
# define FMT_REMOVE_TRANSITIVE_INCLUDES
|
||||
#endif
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <cmath> // std::signbit
|
||||
# include <cstdint> // uint32_t
|
||||
# include <cstring> // std::memcpy
|
||||
@ -56,15 +56,14 @@
|
||||
#include "base.h"
|
||||
|
||||
// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
|
||||
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && \
|
||||
!defined(FMT_IMPORT_STD)
|
||||
#if FMT_HAS_INCLUDE(<bit>) && FMT_CPLUSPLUS > 201703L && !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_MODULE)
|
||||
# include <string_view>
|
||||
# endif
|
||||
# define FMT_USE_STRING_VIEW
|
||||
|
@ -8,8 +8,8 @@
|
||||
#ifndef FMT_OS_H_
|
||||
#define FMT_OS_H_
|
||||
|
||||
#include <cerrno>
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <cerrno>
|
||||
# include <cstddef>
|
||||
# include <cstdio>
|
||||
# include <system_error> // std::system_error
|
||||
@ -18,7 +18,7 @@
|
||||
#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
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_OSTREAM_H_
|
||||
#define FMT_OSTREAM_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <fstream> // std::filebuf
|
||||
#endif
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_PRINTF_H_
|
||||
#define FMT_PRINTF_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <algorithm> // std::max
|
||||
# include <limits> // std::numeric_limits
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_RANGES_H_
|
||||
#define FMT_RANGES_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <initializer_list>
|
||||
# include <iterator>
|
||||
# include <string>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_STD_H_
|
||||
#define FMT_STD_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <atomic>
|
||||
# include <bitset>
|
||||
# include <complex>
|
||||
@ -29,7 +29,7 @@
|
||||
# include <version>
|
||||
#endif
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
// Checking FMT_CPLUSPLUS for warning suppression in MSVC.
|
||||
# if FMT_CPLUSPLUS >= 201703L
|
||||
# if FMT_HAS_INCLUDE(<filesystem>)
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef FMT_XCHAR_H_
|
||||
#define FMT_XCHAR_H_
|
||||
|
||||
#ifndef FMT_IMPORT_STD
|
||||
#ifndef FMT_MODULE
|
||||
# include <cwchar>
|
||||
#endif
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "format.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>
|
||||
#endif
|
||||
|
||||
|
@ -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>
|
||||
@ -40,6 +41,8 @@ module;
|
||||
# include <stdint.h>
|
||||
# include <stdio.h>
|
||||
# include <time.h>
|
||||
|
||||
import std;
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
|
78
src/os.cc
78
src/os.cc
@ -12,47 +12,49 @@
|
||||
|
||||
#include "fmt/os.h"
|
||||
|
||||
#include <climits>
|
||||
#ifndef FMT_MODULE
|
||||
# include <climits>
|
||||
|
||||
#if FMT_USE_FCNTL
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
# if FMT_USE_FCNTL
|
||||
# include <sys/stat.h>
|
||||
# include <sys/types.h>
|
||||
|
||||
# ifdef _WRS_KERNEL // VxWorks7 kernel
|
||||
# include <ioLib.h> // getpagesize
|
||||
# ifdef _WRS_KERNEL // VxWorks7 kernel
|
||||
# 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
|
||||
|
||||
# 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
|
||||
|
||||
namespace {
|
||||
|
Loading…
Reference in New Issue
Block a user