Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redefinition of struct fmt_detail::time_zone when compile with fmt #649

Open
zhangzq opened this issue Jan 23, 2025 · 2 comments
Open

redefinition of struct fmt_detail::time_zone when compile with fmt #649

zhangzq opened this issue Jan 23, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@zhangzq
Copy link

zhangzq commented Jan 23, 2025

Describe the bug

I used fmt in my project. But got redefinition of struct fmt_detail::time_zone error when compile my project.

I found the problem is quill/std/FilesystemPath.h. Everything are find when I not include this path.

To Reproduce

the example code (save in t.cpp):

#include "quill/Backend.h"
#include "quill/Frontend.h"
#include "quill/LogMacros.h"
#include "quill/Logger.h"
#include "quill/sinks/ConsoleSink.h"
#include <string_view>
#include "fmt/base.h"

#include "quill/std/Array.h"
#include "quill/std/Vector.h"
#include "quill/std/FilesystemPath.h"
#include "fmt/std.h"
#include "fmt/ranges.h"

int main()
{
  quill::Backend::start();

  quill::Logger* logger = quill::Frontend::create_or_get_logger(
    "root", quill::Frontend::create_or_get_sink<quill::ConsoleSink>("sink_id_1"));
                                                                                                                                                                                                                                                                                          fmt::print("{}", std::vector<int>{{1, 2, 3}});

  LOG_INFO(logger, "Hello from {}!", std::string_view{"Quill"});
}

when compile with (the quill/fmt headers installed in /opt/include, and quill/fmt library installed in /opt/lib):

g++ t.cpp -o t -I /opt/include -L /opt/lib -l quill -l fmt

result in following compile error:

In file included from /opt/include/fmt/ostream.h:23,
                 from /opt/include/fmt/std.h:12,
                 from t.cpp:13:
/opt/include/fmt/chrono.h:26:8: error: redefinition of ‘struct fmt_detail::time_zone’
   26 | struct time_zone {
      |        ^~~~~~~~~
In file included from /opt/include/quill/bundled/fmt/ostream.h:23,
                 from /opt/include/quill/bundled/fmt/std.h:12,
                 from /opt/include/quill/std/FilesystemPath.h:16,
                 from t.cpp:12:
/opt/include/quill/bundled/fmt/chrono.h:26:8: note: previous definition of ‘struct fmt_detail::time_zone’
   26 | struct time_zone {
      |        ^~~~~~~~~
/opt/include/fmt/chrono.h:33:38: error: redefinition of ‘template<class ... T> fmt_detail::time_zone* fmt_detail::current_zone(T ...)’
   33 | template <typename... T> inline auto current_zone(T...) -> time_zone* {
      |                                      ^~~~~~~~~~~~
/opt/include/quill/bundled/fmt/chrono.h:33:38: note: ‘template<class ... T> fmt_detail::time_zone* fmt_detail::current_zone(T ...)’ previously declared here
   33 | template <typename... T> inline auto current_zone(T...) -> time_zone* {
      |                                      ^~~~~~~~~~~~
/opt/include/fmt/chrono.h:37:38: error: redefinition of ‘template<class ... T> void fmt_detail::_tzset(T ...)’
   37 | template <typename... T> inline void _tzset(T...) {}
      |                                      ^~~~~~
/opt/include/quill/bundled/fmt/chrono.h:37:38: note: ‘template<class ... T> void fmt_detail::_tzset(T ...)’ previously declared here
   37 | template <typename... T> inline void _tzset(T...) {}
      |                                      ^~~~~~

Expected Behaviour

There should be no conflict.

Environment Details

using quill master (be6c292),and fmt master (aabe6391), in ubuntu 24.04, with default gcc 13.3.0.

@odygrd
Copy link
Owner

odygrd commented Jan 23, 2025

thanks a lot for reporting this. This new namespace was introduced in the latest libfmt release and that is a bit unexpected. I will release a new version with a fix once libfmt 11.1.3 is available.

It has to be renamed to fmtquill_detail but the ideal solution would be if in libfmt the existing fmt::detail namespace is used

@odygrd odygrd added the bug Something isn't working label Jan 23, 2025
@odygrd
Copy link
Owner

odygrd commented Jan 23, 2025

fmtlib/fmt#4324

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants