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

compile error ".parse" is not a member #2805

Closed
HerrDingenz opened this issue Jul 8, 2023 · 6 comments
Closed

compile error ".parse" is not a member #2805

HerrDingenz opened this issue Jul 8, 2023 · 6 comments

Comments

@HerrDingenz
Copy link

HerrDingenz commented Jul 8, 2023

After updating spdlog to the latest version I get the compile error: ".parse is not a member of ......"

My code worked perfectly fine before I updated spdlog. It seems like the commit 62e55e7 broke it.

Here's an example of what isn't working anymore. I have a struct with some data in it that i want to log:

struct SomeData
{
   int a = 0;
   float b = 0.0f;
   bool c = false;

   friend std::ostream& operator << (std::ostream& os, const SomeData& data) noexcept
   {
      return os << std::boolalpha << "Data: a = " << data.a << ", b = " << data.b << ", c = " << data.c << '\n';
   }
};

int main()
{
   SomeData data{10, 23.23f, true};
   std::cout << data;				// works

   // let's assume I have a proper working spdlog::logger for the console that also includes <spdlog/fmt/ostr.h>
   my_loggger->trace(data);			// ERROR: .parse is not a member
}

If I construct the object and send it std::cout it works like expected and prints the data to the console. However when sending it to spdlog it won't compile.
When I checkout the commit right before the previously mentioned one ( b85c509 ) everything works fine.

EDIT: I forgot to mention I am in VS2022, c++latest (C++23)

@gabime
Copy link
Owner

gabime commented Jul 8, 2023

See the example how to format your own classes in fmtlib 10.

@HerrDingenz
Copy link
Author

Thanks for your response. So you're telling me to change my whole codebase and write formatters for every single type just because you upgraded to fmtlib 10? It all worked perfectly fine with my code example before you upgraded to fmtlib 10.

@gabime
Copy link
Owner

gabime commented Jul 8, 2023

You don't have to upgrade. It will be released in spdlog version 2.0 since it is a breaking change.

@gabime
Copy link
Owner

gabime commented Jul 8, 2023

As a quick fix, note you can just do

#include "spdlog/fmt/ostr.h" // support for user defined types
template <> struct fmt::formatter<SomeData> : ostream_formatter {};

In any case, I think I will revert the upgrade to fmt 10 in this branch to avoid confusion (and re-apply in version 2 branch).

@gabime
Copy link
Owner

gabime commented Jul 8, 2023

Fixed in 4338b9c

@gabime gabime closed this as completed Jul 8, 2023
@HerrDingenz
Copy link
Author

thank you .. now everything works again on latest commit without me having to write all those formatters myself :)

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