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

Use std::function for the global error handler #1971

Merged
merged 1 commit into from
Jun 15, 2021
Merged

Use std::function for the global error handler #1971

merged 1 commit into from
Jun 15, 2021

Conversation

SpriteOvO
Copy link
Contributor

@SpriteOvO SpriteOvO commented Jun 15, 2021

// error C2664: 'void spdlog::set_error_handler(void (__cdecl *)(const std::string &))': cannot convert argument 1 from '<lambda_1>' to 'void (__cdecl *)(const std::string &)'
//
spdlog::set_error_handler([&](const std::string &message) { /* ... */ });
spdlog::set_error_handler([=](const std::string &message) { /* ... */ });

The pure pointer function type error handler cannot store lambda with capture or std::bind.

I think this might be a mistake? Because the error handler in spdlog::logger is using err_handler (std::function).

This PR changes the global error handler type from a pure pointer function (void (*)(const std::string &msg)) to err_handler (std::function<void(const std::string &err_msg)>) to fix that problem.

@gabime gabime merged commit 12df172 into gabime:v1.x Jun 15, 2021
@gabime
Copy link
Owner

gabime commented Jun 15, 2021

Thanks @SpriteOvO . Merged.

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

Successfully merging this pull request may close these issues.

2 participants