From d842c0c0400d246f9ddcbc1058285d532183d32c Mon Sep 17 00:00:00 2001 From: LoveSy Date: Thu, 6 Jun 2024 21:56:04 +0800 Subject: [PATCH] Fix missing includes in fmt.cc This causes duplicated std definitions in the fmt module --- CMakeLists.txt | 2 ++ include/fmt/base.h | 9 ++++++--- src/fmt.cc | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89ed7520a58ef..882e4416488d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ function(add_module_library name) target_compile_options(${name} PUBLIC -fmodules-ts) endif () + target_compile_definitions(${name} PRIVATE FMT_MODULE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja") target_sources(${name} PUBLIC FILE_SET CXX_MODULES FILES ${sources}) else() diff --git a/include/fmt/base.h b/include/fmt/base.h index 6b1d8140c29b9..2e10a4c3b423b 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -8,9 +8,12 @@ #ifndef FMT_BASE_H_ #define FMT_BASE_H_ -#include // CHAR_BIT -#include // FILE -#include // strlen +// c headers are preferable for performance reasons +#ifndef FMT_MODULE +# include // CHAR_BIT +# include // FILE +# include // strlen +#endif #ifndef FMT_IMPORT_STD // is also included transitively from . diff --git a/src/fmt.cc b/src/fmt.cc index bb3845f2f964e..b7e5ccd4c8132 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -6,6 +6,7 @@ module; # include # include # include +# include # include # include # include @@ -13,6 +14,7 @@ module; # include # include # include +# include # include # include # include @@ -22,6 +24,7 @@ module; # include # include # include +# include # include # include # include @@ -104,7 +107,9 @@ extern "C++" { #if FMT_OS # include "fmt/os.h" #endif +#include "fmt/ostream.h" #include "fmt/printf.h" +#include "fmt/ranges.h" #include "fmt/std.h" #include "fmt/xchar.h"