diff --git a/include/fmt/args.h b/include/fmt/args.h index d45b965bc51a6..31a60e8faf1a6 100644 --- a/include/fmt/args.h +++ b/include/fmt/args.h @@ -8,7 +8,7 @@ #ifndef FMT_ARGS_H_ #define FMT_ARGS_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::reference_wrapper # include // std::unique_ptr # include diff --git a/include/fmt/base.h b/include/fmt/base.h index 27cc293126550..5a6dadcdf3e61 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -8,6 +8,10 @@ #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 // CHAR_BIT @@ -15,12 +19,10 @@ # include // strlen #endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifdef FMT_MODULE // is also included transitively from . # include // std::byte # include // std::enable_if -#elif !defined(FMT_MODULE) -import std; #endif // The fmt library version in the form major * 10000 + minor * 100 + patch. diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 3406a4a673f2f..c93123fd33532 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -8,7 +8,7 @@ #ifndef FMT_CHRONO_H_ #define FMT_CHRONO_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include // std::isfinite diff --git a/include/fmt/compile.h b/include/fmt/compile.h index a98e1bc0531bf..b2afc2c309f43 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -8,7 +8,7 @@ #ifndef FMT_COMPILE_H_ #define FMT_COMPILE_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::back_inserter #endif diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index db6d74d4c95f3..8ae7f69b2c4a2 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -8,7 +8,7 @@ #ifndef FMT_FORMAT_INL_H_ #define FMT_FORMAT_INL_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include @@ -18,7 +18,7 @@ # include // errno # include -# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) +# if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_MODULE) # include # endif #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index bfdb2e0e3fe8f..dc075d8d455ff 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -38,7 +38,7 @@ # define FMT_REMOVE_TRANSITIVE_INCLUDES #endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::signbit # include // uint32_t # include // std::memcpy @@ -57,14 +57,14 @@ // Checking FMT_CPLUSPLUS for warning suppression in MSVC. #if FMT_HAS_INCLUDE() && FMT_CPLUSPLUS > 201703L && \ - !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) + !defined(FMT_MODULE) # include // std::bit_cast #endif // libc++ supports string_view in pre-c++17. #if FMT_HAS_INCLUDE() && \ (FMT_CPLUSPLUS >= 201703L || defined(_LIBCPP_VERSION)) -# if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +# if !defined(FMT_MODULE) # include # endif # define FMT_USE_STRING_VIEW diff --git a/include/fmt/os.h b/include/fmt/os.h index 5462661a026a5..5344e5c2378bd 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -10,11 +10,9 @@ #ifndef FMT_MODULE # include -# ifndef FMT_IMPORT_STD -# include -# include -# include // std::system_error -# endif +# include +# include +# include // std::system_error #endif #include "format.h" diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 0be26709dcd0d..98faef659f527 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -8,7 +8,7 @@ #ifndef FMT_OSTREAM_H_ #define FMT_OSTREAM_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::filebuf #endif diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 3b2b9b4be8b32..ee4b06fd5e724 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -8,7 +8,7 @@ #ifndef FMT_PRINTF_H_ #define FMT_PRINTF_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include // std::max # include // std::numeric_limits #endif diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 624a6241559cb..68e75ab36fb0e 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -8,7 +8,7 @@ #ifndef FMT_RANGES_H_ #define FMT_RANGES_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include diff --git a/include/fmt/std.h b/include/fmt/std.h index 5f1f403c41eeb..01635e18a43b4 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -8,7 +8,7 @@ #ifndef FMT_STD_H_ #define FMT_STD_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include # include # include @@ -29,7 +29,7 @@ # include #endif -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE // Checking FMT_CPLUSPLUS for warning suppression in MSVC. # if FMT_CPLUSPLUS >= 201703L # if FMT_HAS_INCLUDE() diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 31bdccdb97eed..6c19bf3e722f4 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -8,7 +8,7 @@ #ifndef FMT_XCHAR_H_ #define FMT_XCHAR_H_ -#if !defined(FMT_IMPORT_STD) && !defined(FMT_MODULE) +#ifndef FMT_MODULE # include #endif @@ -16,8 +16,7 @@ #include "format.h" #include "ranges.h" -#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_IMPORT_STD) && \ - !defined(FMT_MODULE) +#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) && !defined(FMT_MODULE) # include #endif diff --git a/src/fmt.cc b/src/fmt.cc index 108f15312b3b4..28f4bb821ad8d 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -41,6 +41,8 @@ module; # include # include # include + +import std; #endif #include #include diff --git a/src/os.cc b/src/os.cc index 81177b263e486..7bc18e2a8e510 100644 --- a/src/os.cc +++ b/src/os.cc @@ -12,47 +12,49 @@ #include "fmt/os.h" -#include +#ifndef FMT_MODULE +# include -#if FMT_USE_FCNTL -# include -# include - -# ifdef _WRS_KERNEL // VxWorks7 kernel -# include // getpagesize -# endif +# if FMT_USE_FCNTL +# include +# include -# ifndef _WIN32 -# include -# else -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN +# ifdef _WRS_KERNEL // VxWorks7 kernel +# include // getpagesize # endif -# include -# 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 +# ifndef _WIN32 +# include +# else +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# include -#ifdef _WIN32 -# include +# 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 +# endif #endif namespace {