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

spdlog type streaming is fragile #1868

Closed
skelly-energid opened this issue Mar 8, 2021 · 2 comments
Closed

spdlog type streaming is fragile #1868

skelly-energid opened this issue Mar 8, 2021 · 2 comments

Comments

@skelly-energid
Copy link

Whether streaming works with spdlog seems to depend on include order and which compiler is used.

Consider this simulation:

// #define WORKING_INCLUDE_ORDER

#ifndef WORKING_INCLUDE_ORDER
#    include <spdlog/spdlog.h>

#    include <spdlog/fmt/ostr.h>
#endif

#include <iostream>

namespace ns
{
    struct Aaa
    {
    };
} // namespace ns

std::ostream& operator<<(std::ostream& os, ns::Aaa const& vec);

#ifdef WORKING_INCLUDE_ORDER

#    include <spdlog/spdlog.h>

#    include <spdlog/fmt/ostr.h>

#endif

void foo()
{
    ns::Aaa aa;
    spdlog::info("none", "Aaa : {}", aa);
}

Compiling with gcc works:

/usr/bin/g++ -isystem spdlog/include -c test.cpp

Compiling with clang fails:

/usr/bin/clang++ -isystem spdlog/include -c test.cpp
spdlog/include/spdlog/fmt/bundled/core.h:1016:5: error: static_assert failed due to requirement 'formattable' "Cannot format argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#formatting-user-defined-types"

Clang also "works" if WORKING_INCLUDE_ORDER is defined.

We encountered this while trying to stream a osg::Vec3 using a operator<< which we define.

@tt4g
Copy link
Contributor

tt4g commented Mar 9, 2021

Since the error message is reported by the fmt library, it is recommended that you open the issue in the fmt project.

@skelly-energid
Copy link
Author

This seems to be related: fmtlib/fmt#2130 At least, this issue can be closed in favor of dealing with it in the context of fmt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants