diff --git a/example/example.cpp b/example/example.cpp index c379c746..b348afb9 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -262,15 +262,23 @@ struct my_type : i(i){}; }; -namespace fmt_lib = spdlog::fmt_lib; + +// Using a namespace alias like fmt_lib is not allowed when extending an existing namespace, +// but the correct namespace can still be selected with the SPDLOG_USE_STD_FORMAT macro. +#ifdef SPDLOG_USE_STD_FORMAT + namespace std { +#else + namespace fmt { +#endif template<> -struct fmt_lib::formatter : fmt_lib::formatter +struct formatter : formatter { auto format(my_type my, format_context &ctx) -> decltype(ctx.out()) { - return fmt_lib::format_to(ctx.out(), "[my_type i={}]", my.i); + return format_to(ctx.out(), "[my_type i={}]", my.i); } }; +} void user_defined_example() { diff --git a/include/spdlog/fmt/bin_to_hex.h b/include/spdlog/fmt/bin_to_hex.h index 93e5c28b..2a5d02c9 100644 --- a/include/spdlog/fmt/bin_to_hex.h +++ b/include/spdlog/fmt/bin_to_hex.h @@ -8,8 +8,10 @@ #include #include -#if defined(__has_include) && __has_include() -# include +#if defined(__has_include) +# if __has_include() +# include +# endif #endif #if __cpp_lib_span >= 202002L