Skip to content

Issues with std::numeric_limits<T>::min/max if WinDef.h is included without #define NOMINMAX #51

@raphgianotti

Description

@raphgianotti

This discussion goes over the issue: https://stackoverflow.com/questions/27442885/syntax-error-with-stdnumeric-limitsmax

I have tested locally and simply enclosing the calls to std::numeric_limits::min/max in parenthesis completely fixes the issues, while changing no functionality on the library, and improves its compatibility with code that includes WinDef.h (which is automatically included with Windows.h).

Example of it on SafeInt.hpp:2536:

From this:

            if( tmp > std::numeric_limits< std::int32_t >::max() ||
                tmp < std::numeric_limits< std::int32_t >::min() )

To this:

            if( tmp > (std::numeric_limits< std::int32_t >::max)() ||
                tmp < (std::numeric_limits< std::int32_t >::min)() )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions