Skip to content

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

Closed
@zhangzq

Description

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.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions