Hazel icon indicating copy to clipboard operation
Hazel copied to clipboard

error C2079: '_' uses undefined struct 'fmt::v10::detail::type_is_unformattable_for<T,char>'

Open hoyeziyu opened this issue 1 year ago • 15 comments

I wonder why? Thank you! error C2079: '_' uses undefined struct 'fmt::v10::detail::type_is_unformattable_for<T,char>' error C2338: Cannot format an argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#udt

Log.h

#include <memory>
#include "Core.h"
#include "spdlog/spdlog.h"
#include "spdlog/fmt/ostr.h"

namespace Hazel {
	class HAZEL_API Log
	{
	public:
		static void Init();

		inline static std::shared_ptr<spdlog::logger>& GetCoreLogger() { return s_CoreLogger; }
		inline static std::shared_ptr<spdlog::logger>& GetClientLogger() { return s_ClientLogger; }
	private:
		static std::shared_ptr<spdlog::logger> s_CoreLogger;
		static std::shared_ptr<spdlog::logger> s_ClientLogger;
	};
}

Log.cpp

#include "Log.h"
#include "spdlog/sinks/stdout_color_sinks.h"


namespace Hazel {
	std::shared_ptr<spdlog::logger> Log::s_CoreLogger;
	std::shared_ptr<spdlog::logger> Log::s_ClientLogger;


	void Log::Init() {
		spdlog::set_pattern("%^[%T] %n:%v%$");
		s_CoreLogger = spdlog::stdout_color_mt("Hazel");
		s_CoreLogger->set_level(spdlog::level::trace);

		s_ClientLogger = spdlog::stdout_color_mt("App");
		s_ClientLogger->set_level(spdlog::level::trace);
	}
}

image

hoyeziyu avatar Sep 19 '24 12:09 hoyeziyu

bro,i have the same question, you fix it?

323931 avatar Sep 22 '24 10:09 323931

bro,i have the same question, you fix it?

There's a fix in Cherno's discord server in the Game-Engine-Series channel, but you might have to scroll up quite a bit 👍

VagueLobster avatar Sep 22 '24 10:09 VagueLobster

bro,i have the same question, you fix it?

There's a fix in Cherno's discord server in the Game-Engine-Series channel, but you might have to scroll up quite a bit 👍

thank you bro,do you have a url? i do not know how to get the discord

323931 avatar Sep 22 '24 11:09 323931

thank you bro,do you have a url? i do not know how to get the discord

It's in the readme

Kirdow avatar Sep 22 '24 11:09 Kirdow

thank you bro,do you have a url? i do not know how to get the discord

It's in the readme

Thank you!!!!!!!!!

323931 avatar Sep 22 '24 11:09 323931

bro,i have the same question, you fix it?

There's a fix in Cherno's discord server in the Game-Engine-Series channel, but you might have to scroll up quite a bit 👍

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you

hoyeziyu avatar Sep 23 '24 01:09 hoyeziyu

bro,i have the same question, you fix it?

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you

hoyeziyu avatar Sep 23 '24 01:09 hoyeziyu

bro,i have the same question, you fix it?

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you

bro,i fixed it,you can use e.ToString() instead of e 微信图片_20240924111806

323931 avatar Sep 24 '24 03:09 323931

bro,i have the same question, you fix it?老哥,我也有同样的问题,你解决了吗?

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you不,我还没解决。您找到解决问题的信息了吗?有没有具体的时间我们可以找到信息来解决问题?谢谢

bro,i fixed it,you can use e.ToString() instead of e兄弟,我修好了,你可以用 e.ToString() 代替 e 微信图片_20240924111806

Okay, thanks. I'll go back and try

hoyeziyu avatar Sep 24 '24 04:09 hoyeziyu

bro,i have the same question, you fix it?

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you

bro,i fixed it,you can use e.ToString() instead of e 微信图片_20240924111806

Thank's bro, it work

biigHandsomeGuy avatar Dec 16 '24 13:12 biigHandsomeGuy

Does anyone know how to solve this in the RegisterComponent() function in ScriptGlue.cpp ? None of the existing solutions seem applicable.

jackpsmith-git avatar Dec 27 '24 22:12 jackpsmith-git

老哥,我也有同样的问题,你解决了吗?老哥,我也有同样的问题,你解决了吗?

不,我还没解决。您找到解决问题的信息了吗?有没有具体的时间我们可以找到信息来解决问题?谢谢不,我还没有解决。您找到解决问题的信息了吗?没有具体的时间我们可以找到解决问题的信息吗?谢谢

兄弟,我修好了,你可以用e.ToString()代替e兄弟,我修好了,你可以用e.ToString()代替e微信图片_20240924111806

好的,谢谢。我会回去试试

thank you this help

hongyesuifeng avatar May 26 '25 00:05 hongyesuifeng

bro,i have the same question, you fix it?

No, I haven't solved it yet. Did you find the information that solved the problem? Is there a specific time when we can locate the information to solve the problem? Thank you

bro,i fixed it,you can use e.ToString() instead of e 微信图片_20240924111806

i dont think so, this defeats the purpose intended to, as in to pass the object as arg, and using the overloaded function for operater<<(Event e) definition, it must be able to change it to string automaticlly

Xtremely-Doped-Punk avatar Jun 24 '25 04:06 Xtremely-Doped-Punk

here is the solution comment made in discord server. I am just forwarding it, hope it helps:

this worked with older version, I guess:

inline std::ostream& operator<<(std::ostream& os, const Event& e)
{
    return os << e.ToString();
}

But for newer version we need to use this instead:

inline std::string format_as(const Event& e) {
    return e.ToString();
}

i have tried this, and it works. hopefully we can close this issue :) Refernce: https://fmt.dev/latest/api/#udt

There are two ways to make a user-defined type formattable: providing a format_as function or specializing the formatter struct template. The format_as function should take an object of your type and return an object of a formattable type.

Xtremely-Doped-Punk avatar Aug 26 '25 18:08 Xtremely-Doped-Punk

hey, I have this same problem except with the types glm::vec3, const std::filesystem::path, std::filesystem::path, and Hazel::UUID. how would i create the format_as functions for these?

edit: nvm fixed it myself 👍

UnpaintedKitchens avatar Sep 09 '25 19:09 UnpaintedKitchens