Skip to content

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

Description

@ToddWilsonBertec

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions