diff --git a/include/fmt/core.h b/include/fmt/core.h index bf95038d61d35..67fca8b61ab6a 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -238,6 +238,7 @@ #ifndef FMT_MODULE_EXPORT # define FMT_MODULE_EXPORT +# define FMT_MODULE_EXPORT_CONSTANT static # define FMT_MODULE_EXPORT_BEGIN # define FMT_MODULE_EXPORT_END # define FMT_BEGIN_DETAIL_NAMESPACE namespace detail { diff --git a/include/fmt/os.h b/include/fmt/os.h index c447831e5562d..2d14953a8beee 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -394,7 +394,7 @@ struct ostream_params { FMT_END_DETAIL_NAMESPACE -static constexpr detail::buffer_size buffer_size; +FMT_MODULE_EXPORT_CONSTANT constexpr detail::buffer_size buffer_size; /** A fast output stream which is not thread-safe. */ class FMT_API ostream final : private detail::buffer { diff --git a/src/fmt.cc b/src/fmt.cc index d0d6e7fb348d4..23234e7a597f3 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -2,6 +2,9 @@ module; #ifndef __cpp_modules # error Module not supported. #endif +#ifdef _MSC_VER +# pragma warning(disable : 4702) +#endif // put all implementation-provided headers into the global module fragment // to prevent attachment to this module @@ -71,6 +74,7 @@ module; export module fmt; #define FMT_MODULE_EXPORT export +#define FMT_MODULE_EXPORT_CONSTANT #define FMT_MODULE_EXPORT_BEGIN export { #define FMT_MODULE_EXPORT_END } #define FMT_BEGIN_DETAIL_NAMESPACE \ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dcf3f4ac258e4..720bea19e7335 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -99,8 +99,10 @@ if (FMT_CAN_MODULE) add_fmt_test(module-test MODULE) if (MSVC) - target_compile_options(test-module PRIVATE /utf-8) - target_compile_options(module-test PRIVATE /utf-8) + target_compile_options(test-module PRIVATE /utf-8 /Zc:__cplusplus + /Zc:externConstexpr /Zc:inline) + target_compile_options(module-test PRIVATE /utf-8 /Zc:__cplusplus + /Zc:externConstexpr /Zc:inline) endif () endif ()