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

chrono.h formatter conflict with min macro #3325

Closed
ToddWilsonBertec opened this issue Feb 26, 2023 · 0 comments · Fixed by #3326
Closed

chrono.h formatter conflict with min macro #3325

ToddWilsonBertec opened this issue Feb 26, 2023 · 0 comments · Fixed by #3326

Comments

@ToddWilsonBertec
Copy link

In the template method:

template <typename Char, typename Duration>
struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
Char> : formatter<std::tm, Char> {.....

if (epoch.count() < (Duration::min() + second).count())
FMT_THROW(format_error("duration is too small"));

MSVC (and probably others) will fail to compile because often the stupid min/max macros are defined.

Simple fix is to put parentheses around Duration::min, like so:
if (epoch.count() < ( ( Duration::min ) () + second).count())

phprus added a commit to phprus/fmt that referenced this issue Feb 26, 2023
Signed-off-by: Vladislav Shchapov <[email protected]>
vitaut pushed a commit that referenced this issue Feb 26, 2023
Signed-off-by: Vladislav Shchapov <[email protected]>
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 a pull request may close this issue.

1 participant