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 write_fractional_seconds std::max/min needs explict type #3228

Closed
ToddWilsonBertec opened this issue Dec 14, 2022 · 0 comments · Fixed by #3229
Closed

chrono write_fractional_seconds std::max/min needs explict type #3228

ToddWilsonBertec opened this issue Dec 14, 2022 · 0 comments · Fixed by #3229

Comments

@ToddWilsonBertec
Copy link

Depending on the project that is consuming fmt{} (particularly Windows), min and max may be defined as macros, which causes compile errors in write_fractional_seconds. Specifically, lines 1056 and 1067:

int leading_zeroes = std::max(0, num_fractional_digits - num_digits);
leading_zeroes = std::min(leading_zeroes, precision);

While #undef'ng both min and max is one solution, this can break other compilation bits that still expect them to be defined.

A portable solution that doesn't resort to macro finagling is to explicitly use the data type:
int leading_zeroes = std::max(0, num_fractional_digits - num_digits);
leading_zeroes = std::min(leading_zeroes, precision);

phprus added a commit to phprus/fmt that referenced this issue Dec 14, 2022
Signed-off-by: Vladislav Shchapov <[email protected]>
vitaut pushed a commit that referenced this issue Dec 14, 2022
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